A button that opens a calendar in a popover.
$ pnpm dlx shadcn@latest add https://dashral.com/r/date-picker.jsonInstallation
$ pnpm dlx shadcn@latest add https://dashral.com/r/date-picker.jsonAdds the component, the components it builds on, its npm packages and the theme tokens it uses. Using Dashral often? Add the registry to components.json once:
{
"registries": {
"@dashral": "https://dashral.com/r/{name}.json"
}
}Then add components by name:
$ pnpm dlx shadcn@latest add @dashral/date-pickerUsage
import { DatePicker } from "@/components/dashral/date-picker"
<DatePicker label="Due date" disabledDays={{ before: new Date() }} />Examples
API reference
DatePicker
| Prop | Type | Default |
|---|---|---|
value / defaultValue | DatePicked day, controlled or initial. | — |
onValueChange | (value: Date | undefined) => voidCalled with the new value. | — |
placeholder | stringShown before a day is picked. | "Pick a date" |
locale / formatOptions | string / Intl.DateTimeFormatOptionsHow the picked day is written. | LocaleProvider's / { dateStyle: "medium" } |
disabledDays | MatcherDays that can't be picked, e.g. { before: new Date() }. | — |
disabled | booleanThe whole picker can't be used. | false |
label | ReactNodeShown above, linked to the control. | — |
description | ReactNodeA hint under the control. | — |
error | boolean | ReactNodetrue shows the error style; a message also shows under the control. | — |
labelAction | ReactNodeAt the end of the label's row, e.g. a “Forgot password?” link or the current value. | — |
withAsterisk | booleanMarks the label with an asterisk, e.g. alongside required. | false |
classNames | { root, label, description, error, trigger, content }Classes for each part. | — |
Keyboard
| Keys | Action |
|---|---|
| EnterorSpace | Open the calendar |
| Arrow keysorPage UporPage Down | Move by day, week or month in the calendar |
| Enter | Pick and close |
| Escape | Close |
Accessibility
- The calendar takes focus when it opens and gives it back to the button when it closes.
Motion
- Opens with a fade, a scale from 95%, a 2px blur clearing and a 4px slide from its trigger's side, on the spring (--duration-standard); closes faster (--duration-fast, --ease-exit). No blur with reduced motion.