Date Picker
DatePicker is a single-date input that pairs a text-style trigger with a calendar popover.
import { DatePicker } from '@/components/ui/wideset/datepicker/DatePicker';
<DatePicker className="w-[18rem] max-w-full" defaultSelected="2026-11-03" />Installation
pnpm dlx wideset add date-picker
Copies the component and any Wideset components it uses into your project.
Examples
Variants
Primary is the field's normal state. Danger marks a date that failed validation, such as a due date in the past; pair it with an error message under the field (Form field does that), because the red border alone tells a screen reader nothing.
import { DatePicker } from '@/components/ui/wideset/datepicker/DatePicker';
export default function DatePickerVariants() {
return (
<div className="gap-ws-12 flex w-[18rem] max-w-full flex-col">
{(['primary', 'danger'] as const).map((variant) => (
<DatePicker key={variant} variant={variant} defaultSelected="2026-11-03" />
))}
</div>
);
}Presets
Border outlines the field, for forms where it sits among other inputs. Ghost drops the outline and adds a leading calendar icon, for toolbars and filter rows where the field should read as part of the surface. Keep one preset per form.
import { DatePicker } from '@/components/ui/wideset/datepicker/DatePicker';
export default function DatePickerPresets() {
return (
<div className="gap-ws-12 flex w-[18rem] max-w-full flex-col">
{(['border', 'ghost'] as const).map((preset) => (
<DatePicker key={preset} preset={preset} defaultSelected="2026-11-03" />
))}
</div>
);
}Sizes
Medium is the default. Small fits dense tables and filter bars; large gives the field more presence and a bigger hit area on touch screens. Match the size of the inputs next to it.
import { DatePicker } from '@/components/ui/wideset/datepicker/DatePicker';
export default function DatePickerSizes() {
return (
<div className="gap-ws-12 flex w-[18rem] max-w-full flex-col">
{(['sm', 'md', 'lg'] as const).map((size) => (
<DatePicker key={size} size={size} defaultSelected="2026-11-03" />
))}
</div>
);
}States
Empty shows the placeholder, so phrase it as the thing to pick ("Pick a due date"). With a date chosen the field shows it in dateFormat, while onSelect always gets an ISO yyyy-MM-dd string. A disabled field does not open and leaves the tab order.
import { DatePicker } from '@/components/ui/wideset/datepicker/DatePicker';
export default function DatePickerStates() {
return (
<div className="gap-ws-12 flex w-[18rem] max-w-full flex-col">
<DatePicker placeholder="Pick a due date" />
<DatePicker defaultSelected="2026-11-03" />
<DatePicker defaultSelected="2026-11-03" disabled />
</div>
);
}API reference
| Name | Description | Default |
|---|---|---|
aria-describedby | Ids of the elements that describe the trigger button, such as a FormField's helper text. string | — |
aria-invalid | Marks the trigger button invalid; FormField sets it while it shows an error. boolean | 'true' | 'false' | 'grammar' | 'spelling' | — |
aria-label | Accessible name of the trigger button when no visible label is associated. string | — |
aria-labelledby | Id of the element that names the trigger button. string | — |
className | Class name to add to the root element. Additional class name forwarded to the trigger element. string | — |
dateFormat | date-fns format string used to render the selected date in the trigger (e.g. `'MMMM d, yyyy'`). string | — |
defaultMotion | Turns the component's built-in animations on or off. When omitted, inherits the value from the nearest `MotionProvider`. boolean | true |
defaultSelected | Initial selected date in ISO format (`YYYY-MM-DD`). Uncontrolled — seeds internal state only. string | — |
disabled | Disables the trigger and prevents the popup from opening. boolean | — |
disabledDates | Dates or matchers that should be unselectable inside the calendar grid. Matcher | Matcher[] | — |
id | Id of the trigger button, so a `<label htmlFor>` can name it. string | — |
onSelect | Fired when a date is picked. Receives the ISO date string (`YYYY-MM-DD`), or `undefined` if cleared. ((day?: string | undefined) => void) | — |
placeholder | Placeholder shown in the trigger when no date is selected. Defaults to `'Pick a date'`. string | 'Pick a date' |
preset | 'border''ghost' | — |
selected | Selected date in ISO format (`YYYY-MM-DD`). Provide to make the component controlled. string | — |
size | 'sm''md''lg' | — |
variant | 'primary''danger' | — |
Accessibility
- Name the trigger:
idplus a<label htmlFor>(orFormFieldhtmlFor), oraria-label. Once named, the chosen date is announced as its description. FormFieldwitherrorTextlinks the message and setsaria-invalid; red alone tells a screen reader nothing, so pairvariant="danger"with an error message.
import { DatePicker } from '@/components/ui/wideset/datepicker/DatePicker';
<DatePicker className="w-[18rem] max-w-full" defaultSelected="2026-11-03" />