DatePicker

Selects a civil date with the system calendar.

  • Native host
  • In the first release
import { DatePicker, datePickerPrimitive } from "nitro-ui-sdk/date-picker";
HeroUI Native
DatePicker (Pro)
Expo UI
DateTimePickerDatePicker
  • DatePicker example screen, light appearance
    Light
  • DatePicker example screen, dark appearance
    Dark
On this page

DatePicker edits a single Gregorian calendar day through the system date control. Use it for due dates, birthdays and other values that carry no time of day.

Anatomy

import { DatePicker } from "nitro-ui-sdk/date-picker";

<DatePicker.Root label="Due date" placeholder="Choose a date" confirmLabel="Done" cancelLabel="Cancel">
  <DatePicker.Label />
  <DatePicker.Trigger />
  <DatePicker.Value />
</DatePicker.Root>;
Part Description
Root Owns the committed day and the pending draft.
Label Visible field name.
Trigger Native field button with a calendar symbol on iOS.
Value Text mirror of the date or placeholder.
Picker An alternate native trigger styled via the picker part.
Confirm / Cancel Optional composed controls for the same picker actions.

Usage

import { DatePicker, civilDate } from "nitro-ui-sdk/date-picker";

<DatePicker.Root label="Due date" placeholder="Choose a date" confirmLabel="Done" cancelLabel="Cancel"
  defaultValue={civilDate("2026-12-15")} minimum={civilDate("2026-12-01")} />;

Variants and sizes

The resolver variant is date. Choose a compact or regular trigger. The default is regular.

States

An empty date shows the placeholder. Minimum and maximum days are inclusive. While editing, the field shows a focus border. Disabled fields block opening and confirmation.

Controlled

import { useState } from "react";
import { DatePicker, type CivilDate } from "nitro-ui-sdk/date-picker";

export function DueDate() {
  const [date, setDate] = useState<CivilDate | null>(null);
  return <DatePicker.Root label="Due date" placeholder="Choose a date" confirmLabel="Done" cancelLabel="Cancel"
    value={date} onValueChange={setDate} />;
}

Use defaultValue for an uncontrolled date. The draft stays private to the picker until confirmation. A veto or an unchanged controlled value declines the confirmation.

Props

Root

Prop Type Default Description
label string required Visible and spoken name.
placeholder string required Text before a date is selected.
hint string — Spoken help for the field.
confirmLabel / cancelLabel string required Localized native actions.
value / defaultValue CivilDate or null null Controlled or initial selected day.
minimum / maximum CivilDate — Inclusive lower and upper bounds.
locale string runtime locale Locale for formatting the trigger value.
onValueChange (date, details) => void — Confirmation callback with action source.
disabled boolean false Prevents opening or confirming.
size DatePickerSize regular Trigger size.
styles PartStyles — Per-part styles.
api Controller — Controller binding.
agentId string — Stable agent identity.
children ReactNode Label and Trigger Custom anatomy.

Trigger, Picker

Prop Type Default Description
part DatePickerPart component part Style part to resolve.

Label, Value, Confirm, Cancel

Prop Type Default Description
part DatePickerPart component part Style part to resolve.
children string matching Root text Override visible text.

Controller API

import { useState } from "react";
import { DatePicker, datePickerPrimitive } from "nitro-ui-sdk/date-picker";

export function DueDate() {
  const [api] = useState(datePickerPrimitive.createApi);
  return <DatePicker.Root api={api} label="Due date" placeholder="Choose" confirmLabel="Done" cancelLabel="Cancel" />;
}
Action Signature Result
open (source?) => ActionStatus Starts editing the committed day or a bounded initial date.
setDate (date, source?) => ActionStatus Sets a valid draft inside the bounds.
confirm (source?) => Promise Attempts a commit and settles controlled changes.
cancel (source?) => ActionStatus Discards the draft and closes.

Styles

import { DatePicker } from "nitro-ui-sdk/date-picker";

<DatePicker.Root label="Due date" placeholder="Choose" confirmLabel="Done" cancelLabel="Cancel"
  styles={{ trigger: ({ tokens }) => ({ style: { cornerRadius: tokens.radius.card } }) }} />;

Resolvers receive tokens, size, date variant, and the open, disabled, value and draft state fields.

Accessibility

The platform button exposes the field’s label, value, hint and disabled state. The picker exposes the native date editor with accessible confirmation and cancel. Focus returns to the trigger on dismissal.

Agent API

Action Arguments Notes
open None Opens the native date picker.
setDate YYYY-MM-DD string Must be a real Gregorian day inside the configured bounds.
confirm None Attempts to commit the current draft.
cancel None Closes and discards the draft.

Platform notes

iOS Android
Implementation Native button and UIDatePicker wheels. Native button and DatePickerDialog.
Verification iOS harness. Implementation written. Build and runtime verification require an Android NDK.