Skip to content

DatePicker

Status: stableAccessibility reviewedtenet-ui@0.4.0
Import
import { DatePicker } from 'tenet-ui';

Source: src/components/DatePicker/DatePicker.tsx

When to use: picking a single date from a compact field that opens a calendar on demand (forms, filters). For an always-visible month grid, use Calendar directly (DatePicker wraps it).

  • Give it an accessible name via FormControl.Label or aria-label.
  • Control it with value + onChange, or leave uncontrolled with defaultValue. onChange hands you a real Date.
  • Constrain with min / max; the popover calendar disables out-of-range days and stops its nav at the boundary.
  • For form submission pass name — it emits a hidden yyyy-mm-dd input. Use size / fullWidth from the scale (block is the deprecated 0.3.0 name and warns) and invalid for validation state.
  • Set weekStartsOn={1} and/or locale for non-US conventions; the displayed date and the calendar both follow them.
  • Never assemble a text input + hand-built dropdown calendar yourself — the popover focus management, the ARIA grid, and the keyboard model are exactly what this composes for you.
  • <DatePicker aria-label="Due date" defaultValue={new Date()} min={new Date()} />
  • ✅ in a form: <FormControl><FormControl.Label>Start date</FormControl.Label><DatePicker name="start" /></FormControl>
  • <TextInput /> next to a <div> calendar wired by hand — no focus trap-out, no roving grid, no Escape handling.
  • ❌ Storing the value as a formatted string — keep the Date; format only for display.

See also: Calendar (the inline grid it wraps), FormControl; system guideline forms.

4 stories for DatePicker — open in Storybook

The full matrix (all args, controls, accessibility panel) is in Storybook.

PropTypeDefaultDescription
valueDate | nullControlled selected date (null = empty).
defaultValueDate | nullUncontrolled initial selected date.
onChange(date: Date) => voidCalled with the chosen date.
minDateEarliest selectable day (inclusive).
maxDateLatest selectable day (inclusive).
weekStartsOnWeekStart0First day of the week: 0 = Sunday (default), 1 = Monday.
localestringruntime localeBCP-47 locale for the displayed date + calendar. Defaults to the runtime locale.
placeholderstringSelect a date…Text shown in the trigger when no date is selected.
size'small' | 'medium' | 'large'
DatePickerSize
mediumControl height / font scale.
fullWidthbooleanStretch the trigger to fill the available width.
blockdeprecatedbooleanStretch the trigger to fill the available width.
Deprecated since 0.4.0. Use fullWidth instead (renamed in 0.4.0). block keeps working until 0.5.0.
invalidbooleanfalseInvalid state (danger border + aria-invalid).
disabledbooleanfalseDisable the control.
requiredbooleanfalseRequired (sets aria-required; pairs with FormControl).
namestringForm field name — emits a hidden input (yyyy-mm-dd) so the value submits with a form.
idstringId applied to the trigger (FormControl sets this automatically).
classNamestring
aria-labelstring
aria-describedbystring

Deprecated props keep working for one minor release; the replacement is named in the row.