Date Picker
An outline-tech trigger that reads the chosen date in a mono readout and opens the Calendar on a hard-shadow popover. Controlled via `value`/`onValueChange`, so it drops straight into a Form field.
"use client";import * as React from "react";import { DatePicker } from "@/registry/okibi/ui/date-picker";export default function DatePickerDemo() { const [date, setDate] = React.useState<Date | undefined>(undefined); return <DatePicker value={date} onValueChange={setDate} />;}npx shadcn@latest add https://okibi.cndr.dev/r/date-picker.jsonInstallation
Install the theme first, then add the component:
npx shadcn@latest add https://okibi.cndr.dev/r/date-picker.jsonInstall the required dependencies:
npm install lucide-reactAdd the okibi building blocks it composes: button, calendar, popover.
Copy the source from the Code tab above into components/ui/date-picker.tsx. It uses the cn helper and the okibi theme tokens — install the theme first if you haven't.
Usage
import { DatePicker } from "@/components/ui/date-picker"
const [date, setDate] = React.useState<Date | undefined>(undefined)
<DatePicker value={date} onValueChange={setDate} />API Reference
DatePicker
| Prop | Type | Default | Description |
|---|---|---|---|
value | Date | undefined | – | The selected date (controlled). |
onValueChange | (date: Date | undefined) => void | – | Fires when a date is picked. |
placeholder | string | "Pick a date" | Trigger text when empty. |
disabled | boolean | false | Disable the trigger. |
calendarDisabled | Matcher | Matcher[] | – | Constrain selectable days — forwarded to the Calendar's disabled matcher. |
startMonth | Date | – | Earliest navigable month — forwarded to the Calendar. |
endMonth | Date | – | Latest navigable month — forwarded to the Calendar. |
Accessibility
- The trigger sets
aria-haspopup='dialog'andaria-expandedso assistive tech announces the popover and its open/closed state. - It's a real
Button, so it inherits the 2px signal focus ring plusdisabled:pointer-events-nonewhendisabled. - Keyboard date selection, roving focus, and
autoFocus-on-open are inherited wholesale from the embeddedCalendargrid. - The trigger has no built-in label — wire a
LabelviahtmlFor={id}so the field is named for screen readers. - Picking a day fires
onValueChangeand closes the popover, returning focus to the trigger.
Guidelines
Do
- Always pair an
idwith aLabel htmlForso the control announces what it picks. - Constrain selectable days with
calendarDisabledand bound navigation withstartMonth/endMonthrather than validating after the fact. - Treat it as controlled — own the
Datein state and read it back throughvalue.
Don't
- Don't rely on it for native
<form>submission; it's controlled-only, so serialize theDateyourself. - Don't assume the readout is stable across environments —
toLocaleDateString()follows the runtime locale and timezone.
Calendar
Date-grid calendar (react-day-picker) re-skinned to the HUD — sharp cells, mono uppercase weekday rulers, ghost nav and a signal fill on the selected day.
Combobox
Autocomplete select — a Command palette on a hard-shadow popover with a mono search and a signal check on the active option. Controlled via `value`/`onValueChange`, so it drops straight into a Form field.