ValyroUI Русская версия

Date Field

Date typed segment by segment in the locale order. Free, MIT · Forms and input › Date and time

A date typed in place, segment by segment, in the locale's own order: "дд.мм.гггг", "mm/dd/yyyy", "yyyy/mm/dd" (React Aria's DateField). Digits fill a segment and move on; ArrowUp / ArrowDown step it; Backspace clears it. Each segment is a spinbutton, so a screen reader reads and changes it like a number, and a phone shows its number keyboard. Pair it with a Calendar for picking, or use DatePicker for a field that opens one.

Installation

npx valyro-cli@latest add date-field
npx shadcn@latest add https://valyro.xyz/r/date-field.json
npm install valyro-ui

import 'valyro-ui/styles.css';
import { DateField } from 'valyro-ui';

Props

PropTypeDefault
valueDate | nullControlled value; use with onValueChange.
defaultValueDate | nullnullInitial value when uncontrolled.
onValueChange(value: Date | null) => voidCalled with the date once every segment is filled, and with null when one is cleared.
localestringOrder of day, month and year, the separators and the digits. Defaults to the ThemeProvider locale, then the browser's.
minDateDateEarliest valid day (time of day ignored): an earlier date marks the field invalid.
maxDateDateLatest valid day (time of day ignored): a later date marks the field invalid.
size'sm' | 'md' | 'lg''md'Field height and text size.
disabledbooleanfalseTakes the segments out of the Tab order and leaves the date out of form data.
readOnlybooleanfalseFocusable and readable, not editable.
invalidbooleanfalseDanger border and aria-invalid. Also shown after a submit attempt while a required date is missing.
namestringSubmits the date with the surrounding form as YYYY-MM-DD (empty when incomplete).
requiredbooleanBlocks native form submission while the date is incomplete; aria-required on the segments.
iconReactNode<CalendarIcon />Icon before the segments; null for none. Default: a calendar.
labelsPartial<DateFieldLabels>Overrides for the built-in English text; keys left out keep their defaults.

Related components

Previous: Date Range Picker · Next: Time Picker · All Forms and input