Forms
DateInput
Segmented date (and optional time) field with a calendar popover.
import { DateInput } from "datui";Playground
<DateInput closeOnChange status="default" />Examples
Basic
DD.MM.YYYY
Date and time
enableTime adds hour and minute segments; Done closes.
Accessibility
- The field is a
role="group"; name it witharia-labeloraria-labelledby(FormItem still wires the description andaria-invalid). - Each segment is a
role="spinbutton"with its own label andaria-valuenow/aria-valuetext. Digits fill it and advance, Up/Down step (wrapping), Left/Right move, Backspace deletes and moves back, Delete clears. - Impossible dates (31.02) are not emitted;
onChangegetsnulluntil the segments form a valid date. - The calendar opens in a focus-trapped, labelled dialog with focus on the selected day; Escape or an outside click closes it and focus returns to the calendar button.
- With
name, a hidden input submits the ISO string.
API
DateInput
Segmented date (and optional time) field with a calendar popover. Type digits into DD.MM.YYYY (HH:MM) segments (they auto-advance), Left/Right move, Up/Down step, Backspace clears back. The calendar opens in a focus-trapped dialog and returns focus to its button on Escape / outside click. Give it a name with `aria-label` or `aria-labelledby` (a FormItem label cannot point at a group).
| Prop | Type | Default | Description |
|---|---|---|---|
| after | ReactNode | — | Content after the control, e.g. an icon, clear button or unit. |
| before | ReactNode | — | Content before the control, usually an icon. |
| calendarLabel | string | Calendar | Accessible name of the calendar dialog. |
| calendarPlacement | Placement | bottom-start | |
| changeDayLabel | string | Day | |
| changeHoursLabel | string | "Hours" | |
| changeHoursSegmentLabel | string | Hours | |
| changeMinutesLabel | string | "Minutes" | |
| changeMinutesSegmentLabel | string | Minutes | |
| changeMonthLabel | string | "Month" | |
| changeMonthSegmentLabel | string | Month | |
| changeYearLabel | string | "Year" | |
| changeYearSegmentLabel | string | Year | |
| className | string | — | |
| clearFieldLabel | string | Clear | |
| closeOnChange | boolean | true | Close the calendar after picking a day (ignored with `enableTime`; the Done button closes then). |
| defaultValue | Date | null | |
| disableCalendar | boolean | false | Hide the calendar button. |
| disabled | boolean | — | |
| disableFuture | boolean | — | |
| disablePast | boolean | — | |
| doneButtonDisabled | boolean | — | |
| doneButtonText | string | "Done" | |
| enableTime | boolean | false | Adds hour and minute segments and time pickers. |
| maxDateTime | Date | — | Latest selectable moment; also limits the time pickers on that day. |
| minDateTime | Date | — | Earliest selectable moment; also limits the time pickers on that day. |
| name | string | — | Form field name; a hidden input submits the ISO string. |
| nextMonthLabel | string | "Next month" | |
| onApply | ((value: Date | null) => void) | — | Called when the Done button is pressed (with `enableTime`). |
| onCalendarOpenChange | ((open: boolean) => void) | — | |
| onChange | ((value: Date | null) => void) | — | Called with a valid date once the segments form one, or `null` when cleared / incomplete. |
| prevMonthLabel | string | "Previous month" | |
| readOnly | boolean | — | |
| required | boolean | — | |
| shouldDisableDate | ((date: Date) => boolean) | — | |
| showCalendarLabel | string | Show calendar | |
| size | "s" | "m" | "m" | |
| status | FormFieldStatus | "default" | Visual validation state. Pair `error` with `aria-invalid` on the control (FormItem does this). |
| value | Date | — | |
| weekStartsOn | 0 | 1 | 4 | 2 | 3 | 5 | 6 | 1 | First day of the week, 0 = Sunday. |