Components · Form & Input
Date Picker
Calendar date picker with text input. `granularity` picks a whole month or year.
import { DatePicker } from '@nexub/react';Usage
One date, month or year, typed or picked from a calendar.
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
<DatePicker placeholder="Select a date…" />Examples
Default
With value
With constraints
Month and year
Pay periods and tax years: `'2026-11'` and `'2026'`.
States
defaultdisabledinvalidreadOnlysize="sm"size="md"size="lg"
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| granularity | 'day' | 'day' | 'month' and 'year' show a grid of months or years; the value is then a string, 'YYYY-MM' or 'YYYY'. |
| value | Date | — | Controlled selected date value. |
| onValueChange | ((date: Date) => void) | — | Called with the picked date. |
| locale | Locale | — | 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. |
| placeholder | string | — | Placeholder text displayed in the input when no date is selected. |
| disabled | boolean | false | Disables the date picker input and calendar. |
| minDate | Date | — | Earliest selectable date. Dates before this are greyed out. |
| maxDate | Date | — | Latest selectable date. Dates after this are greyed out. |
| aria-label | string | — | Field name for screen readers; the selected value is appended. |
| id | string | — | Id for the trigger button, e.g. to pair with a <label htmlFor>. |
| className | string | — | |
| disabledDates | Matcher | Matcher[] | — | Days that can't be picked (react-day-picker Matcher), e.g. { dayOfWeek: [0, 6] }. |
| invalid | boolean | — | |
| presets | { label: string; date: Date; }[] | — | Quick picks under the calendar (Today, In a week…); choosing one sets the value and closes. |
| readOnly | boolean | false | Shows the date but the calendar can't open and nothing can be typed; stays focusable. |
| sheet | false | 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' | |
| typeable | boolean | false | The 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.
| Token | Aliases | Notes |
|---|---|---|
| --field-bg | --color-surface-container-lowest | — |
| --field-fg | --color-on-surface | — |
| --field-border | --color-outline | — |
| --field-radius | --shape-field | — |
/* One area of your app */
.checkout {
--field-bg: var(--color-secondary);
}On iOS & Android: DateTimeField
import { DateTimeField } from '@nexub/react-native';
<DateTimeField label="Date of birth" value={dob} onValueChange={setDob} mode="date" />Web vs mobile
Same tokens and prop names. Where the platforms differ:
| Web | iOS & Android | |
|---|---|---|
| Picker | Nexub calendar popover. | The platform date/time picker (needs @react-native-community/datetimepicker). |
Interactive preview of @nexub/react-native rendered for the web. Native chrome (switches, pickers, Liquid Glass) looks like the platform on a device.
On device

iPhone (iOS simulator)

Pixel (Android emulator)
Screenshots from the latest CI run of the showcase app; the live frame renders the same code for the web.
DateTimeField props
| Prop | Type | Default | Description |
|---|---|---|---|
| value | Date | string | null | — | The value; null is empty. A 'YYYY-MM-DD' string is read too. Leave it out for an uncontrolled field. |
| defaultValue | Date | string | null | — | 11.8: the starting value of an uncontrolled field, in the same shape as value. |
| onValueChange | DateTimeFieldChangeHandler | — | Called with the new Date, or null when cleared. |
| granularity | 'day' | 'day' | 11.8: 'month' or 'year' picks a whole month or year instead: see DateTimeFieldPeriodProps. |
| labelrequired | string | — | Visible label above the field; also its accessible name and the picker sheet's title. |
| mode | 'date' | 'time' | 'datetime' | 'date' | What the platform picker edits. 11.8: 'datetime' picks a date and then a time in one field. |
| minDate | Date | — | Earliest date the picker allows. With month or year granularity, earlier months or years are disabled. |
| maxDate | Date | — | Latest date the picker allows. With month or year granularity, later months or years are disabled. |
| placeholder | string | messages.pickDate (pickMonth / pickYear for those granularities) | Text shown while empty. |
| disabled | boolean | false | 11.8: dimmed, can't be opened or cleared, and read as disabled. |
| readOnly | boolean | false | 11.8: shows the value, but the picker can't open and the value can't be cleared. Still focusable. |
| invalid | boolean | false | 11.8: red outline, and the field is marked invalid for screen readers. Give error for a message too. |
| error | string | — | 11.8: error message under the field: red outline, announced, read as the field's hint. |
| size | Extract<ControlSize, 'md' | 'lg' | 'xl'> | 'lg' | 11.8: field height (the TextField sizes). |
| locale | string | the provider's locale | 11.8: BCP 47 locale for the field's text and the iOS picker. |
| disabledDates | DateMatcher | DateMatcher[] | — | 11.8: days that can't be picked: one rule or a list (see DateMatcher), as web. The platform
picker can't grey days out, so picking one keeps the old value and says the day is unavailable.
Presets on such days are disabled. |
| presets | { label: string; date: Date }[] | — | 11.8: quick picks shown as chips under the field (Today, Tomorrow…); a tap sets the value.
In datetime mode the time of the current value (or defaultTime) is kept. Not for time mode
or month and year granularity. |
| minuteStep | number | 1 | 11.8: minutes between choices in time and datetime modes. iOS uses it as the wheel's interval; elsewhere the picked time is rounded to it. |
| clearable | boolean | false | 11.8: a clear button inside the field while it has a value; clearing calls onValueChange(null). |
| loading | boolean | false | 11.8: spinner at the end of the field, and busy for screen readers. |
| defaultTime | string | '09:00' | 11.8: 24-hour "HH:mm" time a date gets when it is picked before any time (date and datetime modes). |
| timeZone | string | — | 11.8: IANA time zone ('Europe/Paris') the value is shown and picked in, with its name under
the field. The value is still an instant (Date). |
| leadingIcon | React.ComponentType<NativeIconProps> | Calendar (Clock in time mode) | 11.8: icon at the start of the field. |
| trailingIcon | React.ComponentType<NativeIconProps> | — | 11.8: icon at the end of the field. |
| leadingAddon | React.ReactNode | — | 11.8: text or a node at the start of the field, e.g. "From". A string is read with the value. |
| trailingAddon | React.ReactNode | — | 11.8: text or a node at the end of the field, e.g. "local time". A string is read with the value. |
| style | StyleProp<ViewStyle> | — | — |