A date picker component that combines a calendar with a trigger element.
The DatePicker
component is built on top of the Calendar
component
and uses a Popover
for the dropdown functionality. It provides
a convenient way to select dates with various trigger elements.
import {
Button,
Calendar,
Popover,
PopoverContent,
PopoverTrigger,
} from "@bun-ui/react"
import { CalendarDays } from "lucide-react"
export const DatePickerBasic = () => {
return (
<Popover>
<PopoverTrigger asChild>
<Button variant="outlined" color="neutral" className="w-40">
<CalendarDays className="mr-2 h-4 w-4" />
Select a date
</Button>
</PopoverTrigger>
<PopoverContent>
<Calendar mode="single" />
</PopoverContent>
</Popover>
)
}
A date picker that allows selecting a date range.
A date picker with an input field trigger.
The DatePicker component is highly customizable as it's built using the Calendar
and Popover
components. You can:
format
function from date-fns