Installation
The Date Picker is built using a composition of the <Popover /> and the <Calendar /> components.
See installation instructions for the Popover and the Calendar components.
Usage
import { format } from 'date-fns'
import { Calendar as CalendarIcon } from 'lucide-react'
import * as React from 'react'
import { Button } from '@/components/ui/button'
import { Calendar } from '@/components/ui/calendar'
import {
Popover,
PopoverContent,
PopoverTrigger,
} from '@/components/ui/popover'const [date, setDate] = React.useState<Date>()<Popover>
<PopoverTrigger render={<Button variant="noShadow" className="w-[280px] justify-start text-left font-base" />}>
<CalendarIcon />
{date ? format(date, "PPP") : <span>Pick a date</span>}
</PopoverTrigger>
<PopoverContent className="w-auto border-0! p-0">
<Calendar
mode="single"
selected={date}
onSelect={setDate}
autoFocus
/>
</PopoverContent>
</Popover>Examples
Default
Basic
A basic date picker component paired with a Field label.
Range Picker
A date picker component for selecting a range of dates.
Date of Birth
A date picker component for selecting a date of birth. This component uses captionLayout="dropdown" for month and year selection.
Input
A date picker component with an Input Group field for typing a date.
Time Picker
A date picker component with a time input field for selecting a time.