Loading component…
Loading component…
Pick one day in the Text Field's look
To reuse this local React demo, copy all files from the Code tab into the same folder, then import DatePicker from ./date-picker.
import { useState } from "react";
import { DatePicker } from "@/components/ui/date-picker";
const weekend = (d: Date) => d.getDay() === 0 || d.getDay() === 6;
export function FirstRun() {
const [day, setDay] = useState<Date | null>(null);
return (
<DatePicker
label="First run"
value={day}
onChange={setDay}
min={new Date()}
isDateDisabled={weekend}
hint="Research Agent only runs on weekdays."
name="firstRun"
/>
);
}| Name | Type | Default | Description |
|---|---|---|---|
| value | Date \| null | The chosen day – makes it controlled; null shows the placeholder | |
| defaultValue | Date \| null | null | Starting day when uncontrolled |
| onChange | (date: Date) => void | Called with the picked day, at local midnight | |
| min | Date | Days before it can't be picked; the month arrow stops there | |
| max | Date | Days after it can't be picked; ignored when it lies before min | |
| isDateDisabled | (date: Date) => boolean | Rules out single days, e.g. weekends or holidays – they stay visible but can't be picked | |
| locale | string | BCP 47 locale for month names, weekdays, digits and the shown value – the browser's by default | |
| weekStartsOn | 0 – 6 | 0 = Sunday … 6 = Saturday – by default the locale's first day of the week | |
| placeholder | string | "Pick a date" | Shown in gray while nothing is chosen |
| label | ReactNode | Shown above the field and read out with the value | |
| hint | ReactNode | A quiet line under the field – the error takes its place while there is one | |
| error | ReactNode | Marks the field invalid (red edge and a faint red fill, aria-invalid) and shows the message where the hint was | |
| optional | boolean | false | Adds "Optional" next to the label |
| size | "sm" \| "md" \| "lg" | "md" | 32 · 36 · 40px high, like the Text Field; taller on touch screens |
| disabled | boolean | false | Dims the field and ignores input |
| name | string | Sends the day as YYYY-MM-DD with a form, through a hidden input | |
| required | boolean | Sets aria-required – check it on submit like any other field | |
| today | Date | Where the today marker sits – the real today by default | |
| defaultOpen | boolean | false | Opens the calendar on mount without taking the focus – for previews |
| aria-label | string | Accessible name when there is no visible label | |
| className | string | Extra class on the wrapper, e.g. a fixed width in a settings row | |
| ref | Ref<HTMLButtonElement> | The field's button – focus it after a validation error |
Fills its container; the calendar stays inside the window and opens above the field near the bottom of the screen
Always six weeks high, so the card never changes height between months
It lives in the top layer (popover), so a card's overflow or z-index never cuts it
Touch screens get 40px days and 16px text; dark mode built in via .dark or data-theme="dark" on an ancestor
@import "tailwindcss"; in your main CSS file.