Docs
Installation
Installation
Install for any React based project.
Install the package
npm i @bryanberger/datepicker
Compose a calendar
Here is an example of a simple calendar styled with Tailwind CSS:
January 2024
Su | Mo | Tu | We | Th | Fr | Sa |
---|---|---|---|---|---|---|
31 | 1 | 2 | 3 | 4 | 5 | 6 |
7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 | 30 | 31 | 1 | 2 | 3 |
import { Calendar } from '@bryanberger/datepicker';
import { ChevronLeft, ChevronRight } from 'lucide-react';
const MyDatePicker = () => {
const today = new Date();
return (
<Calendar
className="border rounded-md p-3"
defaultSelected={ today }
>
<Calendar.Header className="!justify-between !w-full pl-2">
<Calendar.Title />
<div className="space-x-1 flex items-center">
<Calendar.NavButton direction="previous">
<ChevronLeft />
</Calendar.NavButton>
<Calendar.NavButton direction="next" >
<ChevronRight />
</Calendar.NavButton>
</div>
</Calendar.Header>
<Calendar.Content>
<Calendar.Head />
<Calendar.Grid
classNames={ { day: 'h-9 w-9 text-center data-[is-selected=true]:bg-slate-900 data-[is-first=true]:rounded-l-md data-[is-last=true]:rounded-r-md' } }
/>
</Calendar.Content>
</Calendar>
);
};
export default MyDatePicker;