Pick a start and end day on a two-month calendar, or from shortcuts like “Last 7 days”.
$ pnpm dlx shadcn@latest add https://dashral.com/r/date-range-picker.jsonInstallation
$ pnpm dlx shadcn@latest add https://dashral.com/r/date-range-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-range-pickerUsage
import { DateRangePicker } from "@/components/dashral/date-range-picker"
<DateRangePicker label="Period" defaultValue={{ from: new Date(2026, 9, 1), to: new Date(2026, 9, 24) }} />Examples
API reference
DateRangePicker
| Prop | Type | Default |
|---|---|---|
value / defaultValue | DateRange{ from, to }, controlled or initial. | — |
onValueChange | (value: DateRange | undefined) => voidCalled with the new value. | — |
presets | { label: string; range: () => DateRange }[]Shortcuts beside the calendar; [] hides them. | defaultDateRangePresets |
numberOfMonths | numberMonths side by side. | 2 |
locale / formatOptions | string / Intl.DateTimeFormatOptionsHow the range is written on the button. | LocaleProvider's |
disabledDays | MatcherDays that can't be picked. | — |
disabled | booleanThe whole picker can't be used. | false |
placeholder | string | "Pick a date range" |
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. | — |
defaultDateRangePresets
Today, Yesterday, Last 7 days, Last 30 days, This month, Last month — worked out when picked.
Keyboard
| Keys | Action |
|---|---|
| EnterorSpace | Open |
| Tab | Move between the shortcuts and the calendar |
| Enter | Pick a day: the first sets the start, the second the end |
| Escape | Close |
Accessibility
- The shortcuts are a labelled group of buttons; the calendar announces the range as it's picked.
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.