- Docs
- components
- Date Picker
Date Picker
A date picker component with range and presets.
Preview
Code
Installation
CLI
Copy & Paste
npx @sly-cli/sly add jolly-ui date-picker
Note: Only the default style can be installed via CLI at the moment
Usage
"use client"
import React from "react"
import { type DateValue } from "react-aria-components"
import {
Calendar,
CalendarCell,
CalendarGrid,
CalendarGridBody,
CalendarGridHeader,
CalendarHeaderCell,
CalendarHeading,
} from "@/registry/default/ui/calendar"
import {
DatePicker,
DatePickerButton,
DatePickerContent,
} from "@/registry/default/ui/date-picker"
export default function DatepickerDemo({ ...props }) {
const [date, setDate] = React.useState<DateValue>()
return (
<DatePicker shouldCloseOnSelect={false} onChange={setDate} {...props}>
<DatePickerButton date={date} />
<DatePickerContent>
<Calendar>
<CalendarHeading />
<CalendarGrid>
<CalendarGridHeader>
{(day) => <CalendarHeaderCell>{day}</CalendarHeaderCell>}
</CalendarGridHeader>
<CalendarGridBody>
{(date) => (
<>
<CalendarCell date={date} />
</>
)}
</CalendarGridBody>
</CalendarGrid>
</Calendar>
</DatePickerContent>
</DatePicker>
)
}
Examples
Date Picker
Preview
Code
Date Range Picker
Preview
Code
With Presets
Preview
Code