Skip to content
nexubDesign System
v12.7.0

Components · Form & Input

Date Picker

StableAdded v0.0.1 · updated v11.1.0

Calendar date picker with text input. `granularity` picks a whole month or year.

import { DatePicker } from '@nexub/react';
View as Markdown

Usage

Use it for
  • One date, month or year, typed or picked from a calendar.

Use something else for
  • On a page without React (server-rendered HTML, a plain `<form>`): use `<nx-date-picker>` from `@nexub/elements`, the same calendar as a web component.

  • A range: use DateRangePicker. A date and a time: use DateTimePicker.

Playground

Props

size
TSX
<DatePicker placeholder="Select a date…" />

Examples

Default

With value

With constraints

Month and year

Pay periods and tax years: `'2026-11'` and `'2026'`.

States

  • default
  • disabled
  • invalid
  • readOnly
  • size="sm"
  • size="md"
  • size="lg"

Props

Props
PropTypeDefaultDescription
granularity'day''day''month' and 'year' show a grid of months or years; the value is then a string, 'YYYY-MM' or 'YYYY'.
valueDate—Controlled selected date value.
onValueChange((date: Date) => void)—Called with the picked date.
localeLocale—Month and weekday names, week start and the trigger format. Defaults to the NexubProvider dateLocale; the calendar also follows the provider dir, so arrows flip in RTL.
placeholderstring—Placeholder text displayed in the input when no date is selected.
disabledbooleanfalseDisables the date picker input and calendar.
minDateDate—Earliest selectable date. Dates before this are greyed out.
maxDateDate—Latest selectable date. Dates after this are greyed out.
aria-labelstring—Field name for screen readers; the selected value is appended.
idstring—Id for the trigger button, e.g. to pair with a <label htmlFor>.
classNamestring—
disabledDatesMatcher | Matcher[]—Days that can't be picked (react-day-picker Matcher), e.g. { dayOfWeek: [0, 6] }.
invalidboolean—
presets{ label: string; date: Date; }[]—Quick picks under the calendar (Today, In a week…); choosing one sets the value and closes.
readOnlybooleanfalseShows the date but the calendar can't open and nothing can be typed; stays focusable.
sheetfalse | true | 'auto''auto' (pass `sheet={false}` to keep a popover on small screens)true: bottom sheet. 'auto': bottom sheet below the md breakpoint, a popover above.
size'sm' | 'md' | 'lg''md'
typeablebooleanfalseThe trigger is a text input that also accepts a typed date in the locale's short format (date-fns P, e.g. 01/15/2024). Enter or blur commits; an invalid or unavailable date stays as typed, marked aria-invalid, and the value is unchanged. id and aria-label go to the input, ref to the calendar button.

Design tokens

Date Picker reads these component tokens. Each one is unset by default and falls back to the semantic role it aliases, so nothing changes until you set it. Set one on any element to restyle every Date Picker below it, and leave the roles other components share alone. See the three token tiers.

Input, Textarea, Select and Combobox triggers.

Date Picker design tokens
TokenAliasesNotes
--field-bg--color-surface-container-lowest—
--field-fg--color-on-surface—
--field-border--color-outline—
--field-radius--shape-field—
CSS
/* One area of your app */
.checkout {
  --field-bg: var(--color-secondary);
}