Date Picker
Trigger button that opens a popover-anchored calendar for picking a single date or a date range.
Install
Pull Date Picker from the barrel for everyday use, or the granular path when you want a tighter bundle.
import { DatePicker } from "@brika/clay";import { DatePicker } from "@brika/clay/components/date-picker";A minimal example
Drop this into a page. Native HTML attributes pass through to the underlying primitive.
'use client';
import { DatePicker } from '@brika/clay/components/date-picker';
/**
* Uncontrolled trigger, opens a single-month calendar and shows the placeholder until a date is picked.
*/
export default function DatePickerDefaultDemo() {
return <DatePicker placeholder="Pick a date" />;
}Date Picker, every way
Controlled
Controlled with `useState`, the parent owns the selected date and can read or reset it at any time.
Custom Format
Pass any date-fns format string via `formatStr` to change how the trigger label renders.
Range
`DateRangePicker` selects a `from`/`to` pair and renders two months by default.
Accessibility
- Trigger is a real
<button>carryingaria-expandedandaria-controlsfor the popover. - Calendar inside inherits full keyboard navigation from
react-day-picker(arrows, Enter/Space, Page Up/Down). - Selecting a date closes the popover and returns focus to the trigger.
- Provide an external
aria-labelon the trigger when the formatted date alone does not describe the field.
Theme tokens
Every CSS variable Date Picker reads, with its default and the
dotted path you'd write in a ThemeConfig JSON
to override it. Set any of these in your theme to retune Date Picker
without touching component code.
Date Picker tokens
2 tokens--date-picker-trigger-placeholder-colorcolorvar(--muted-foreground)components.datePicker.triggerPlaceholderColorForeground color of the trigger label when no date is selected (the placeholder copy).
--date-picker-trigger-icon-colorcolorvar(--muted-foreground)components.datePicker.triggerIconColorColor of the leading calendar icon rendered inside the trigger button.
Override in a theme
Authoring a theme is plain JSON. Drop overrides under
components.datePicker, the names
are camelCase versions of the variable suffix.
{
"id": "my-theme",
"name": "My Theme",
"description": "...",
"accentSwatches": ["#000"],
"components": {
"datePicker": {
"triggerPlaceholderColor": "var(--muted-foreground)"
}
}
}
Then apply with applyTheme(myTheme)
(see the theming guide),
scope it to a subtree with themeToCssVars(myTheme, mode),
or consume any token directly in your own JSX with the matching Tailwind utility
(e.g. bg-date-picker-…) — see the
chips on each token row.
API reference
Props specific to Date Picker. Native HTML attributes pass through to the underlying primitive, see the component source on GitHub for the full type signature.
<DatePicker />
12 props- string
No description.
- string
No description.
- defaultOpendefault
falsebooleanNo description.
- DateInitial date for uncontrolled mode.
- boolean
No description.
- formatStrdefault
DEFAULT_FORMATstringdate-fns format string applied to the trigger label. Defaults toPPP. - string
No description.
- (open: boolean) => void
No description.
- (value: Date | undefined) => void
No description.
- booleanControlled open state for the popover.
- placeholderdefault
'Pick a date'stringNo description.
- DateControlled selected date. Pair with
onValueChange.
<DateRangePicker />
13 props- string
No description.
- string
No description.
- defaultOpendefault
falsebooleanNo description.
- DateRangeInitial range for uncontrolled mode.
- boolean
No description.
- formatStrdefault
DEFAULT_FORMATstringNo description.
- string
No description.
- numberOfMonthsdefault
2numberNo description.
- (open: boolean) => void
No description.
- (value: DateRange | undefined) => void
No description.
- boolean
No description.
- placeholderdefault
'Pick a date range'stringNo description.
- DateRangeControlled selected range. Pair with
onValueChange.