Forms

Date Picker

Trigger button that opens a popover-anchored calendar for picking a single date or a date range.

Preview
01 Installation

Install

Pull Date Picker from the barrel for everyday use, or the granular path when you want a tighter bundle.

tsxBarrel1 line
import { DatePicker } from "@brika/clay";
tsxGranular1 line
import { DatePicker } from "@brika/clay/components/date-picker";
02 Usage

A minimal example

Drop this into a page. Native HTML attributes pass through to the underlying primitive.

tsxDate Picker.tsx10 lines
'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" />;
}
03 Examples

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.

04 Accessibility

Accessibility

  • Trigger is a real <button> carrying aria-expanded and aria-controls for 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-label on the trigger when the formatted date alone does not describe the field.
05 Tokens 2 theme-overridable

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
ColorFill, border, and text colors.2
  • --date-picker-trigger-placeholder-colorcolorvar(--muted-foreground)
    components.datePicker.triggerPlaceholderColor

    Foreground color of the trigger label when no date is selected (the placeholder copy).

  • --date-picker-trigger-icon-colorcolorvar(--muted-foreground)
    components.datePicker.triggerIconColor

    Color 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.

jsonmy-theme.json12 lines
{
  "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.

06 API reference

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 false
    boolean

    No description.

  • Date
    Initial date for uncontrolled mode.
  • boolean

    No description.

  • formatStrdefault DEFAULT_FORMAT
    string
    date-fns format string applied to the trigger label. Defaults to PPP.
  • string

    No description.

  • (open: boolean) => void

    No description.

  • (value: Date | undefined) => void

    No description.

  • boolean
    Controlled open state for the popover.
  • placeholderdefault 'Pick a date'
    string

    No description.

  • Date
    Controlled selected date. Pair with onValueChange.

<DateRangePicker />

13 props