Founding price: $35, then $79.99 after 23:59 UTC on 4 November, then $79.99
Get ProThis item has no props to tune. Use the lens above to change theme, density, direction and more.
The date picker is built from existing primitives. Add them with the CLI:
The examples format dates with date-fns:
Hold the selected date in state, show it on a trigger button, and render a Calendar inside a Popover:
"use client"
import * as React from "react"
import { format } from "date-fns"
import { CalendarIcon } from "lucide-react"
import { Button } from "@/components/ui/button"
import { Calendar } from "@/components/ui/calendar"
import {
Popover,
PopoverContent,
PopoverTrigger,
} from "@/components/ui/popover"
export function DatePicker() {
const [date, setDate] = React.useState<Date>()
return (
<Popover>
<PopoverTrigger asChild>
<Button variant="outline" className="w-[240px] justify-start">
<CalendarIcon />
{date ? format(date, "PPP") : <span>Pick a date</span>}
</Button>
</PopoverTrigger>
<PopoverContent className="w-auto p-0" align="start">
<Calendar mode="single" selected={date} onSelect={setDate} />
</PopoverContent>
</Popover>
)
}Use mode="range" and keep a DateRange in state. numberOfMonths={2} shows two months side by side.
undefined) when the picker renders on the server, to avoid a hydration mismatch.See the React DayPicker documentation for every Calendar option, including disabled days, locales and time zones.