Rime

DateField

A typed DD/MM/YYYY field with a calendar popover, min/max and a date-of-birth preset.

DateField accepts typing (DD/MM/YYYY, day first) or picking from Calendar. preset="dob" opens on a sensible year with a year dropdown, for dates decades back.

Installation

npx shadcn@latest add KezLahd/rime/date-field

Also installs: base, field, icon, text-input.

Usage

import { DateField } from "@/components/ui";

<Field label="Due date"><DateField value={due} onChange={setDue} /></Field>

Examples

Open

inline shows the calendar open under the field, in place.

Default

API

Generated from the component's TypeScript types and JSDoc (scripts/gen-ui-registry.mjs), so it always matches the source.

DateField

DateField props
PropTypeDefaultDescription
valueRequiredIsoDate | null
onChangeRequired(value: IsoDate | null) => voidnull when cleared or when the typed text is not a usable date.
isDateDisabled(date: IsoDate) => boolean
minIsoDate
maxIsoDate
defaultMonthIsoDateMonth the calendar opens on when empty. For a date of birth, pass ~40 years ago (or use preset="dob").
preset"dob"dob: a date of birth, set up as a sign-up form does it. Month and Year dropdowns in the calendar, years 1920 to this year, no future dates, and an empty field opens 40 years back. Any prop passed explicitly wins over the preset.
captionLayout"label" | "dropdown"The calendar's caption. dropdown gives Month ▾ and Year ▾ quick pickers; see Calendar.
fromYearnumberYear span of the Year picker (dropdown caption only).
toYearnumber
invalidboolean
disabledboolean
requiredboolean
idstring
namestring
placeholderstring"DD/MM/YYYY"
aria-labelstring
classNamestring
inlinebooleanfalseShow the calendar open, in place under the field: no portal, no focus move, no outside-click listener. For docs and thumbnails.

Calendar

Calendar props
PropTypeDefaultDescription
isDateDisabled(date: IsoDate) => booleanDays that cannot be picked. Still focusable, so keyboard users can pass over them.
minIsoDate
maxIsoDate
defaultMonthIsoDateMonth shown first when there is no value. Defaults to today's month.
autoFocusbooleanMoves focus into the grid on mount (used by DateField's popup).
numberOfMonths1 | 2 | 1 | 21Months side by side. Navigation moves them together.
captionLayout"label" | "dropdown" | "label" | "dropdown""label"label: the month and year as a heading, with month and year arrows. dropdown: Month ▾ and Year ▾ buttons that open quick pickers, for dates years away such as a date of birth (a sign-up form). Month arrows stay. Two-month calendars always use labels.
fromYearnumberFirst and last years the Year picker lists (dropdown only). Default to min's and max's years, else 100 years back and 10 on. They also bound the arrows and keyboard paging, so the grid never shows a year the picker lacks.
toYearnumber
classNamestring
valueRequiredIsoDate | null | never
onChangeRequired(value: IsoDate) => void | never
rangenever | DateRangeRange mode. After a start is picked, hovering or arrowing previews the range.
onRangeChangenever | (range: DateRange) => void

Theme tokens

Per-component tokens are undeclared by default, so the default shown is the fallback the CSS uses. Set one at :root (or in theme.css) to restyle every instance. Live values are read from this page, so they follow the Rime Studio.

DateField per-component tokens
TokenDefaultLive value
--field-focus-borderrgba(var(--rgb-brand), 0.7) / var(--focus-color)…
--field-focus-ringvar(--focus-halo)…

System tokens it reads

DateField system tokens
TokenDefaultLive value
--brandtokens.css…
--brand-gradienttokens.css…
--danger-inktokens.css…
--durtokens.css…
--dur-fasttokens.css…
--easetokens.css…
--ease-outtokens.css…
--focus-colortokens.css…
--focus-halotokens.css…
--focus-ringtokens.css…
--font-bodytokens.css…
--glow-smtokens.css…
--ink-bodytokens.css…
--ink-brandtokens.css…
--ink-disabledtokens.css…
--ink-headingtokens.css…
--ink-inversetokens.css…
--ink-mutedtokens.css…
--linetokens.css…
--line-brandtokens.css…
--line-brand-strongtokens.css…
--r-xltokens.css…
--r-xstokens.css…
--rgb-brandtokens.css…
--rgb-brand-deeptokens.css…
--shadow-floattokens.css…
--surface-solidtokens.css…
--text-microtokens.css…
--wash-activetokens.css…
--wash-hovertokens.css…
--wash-strongtokens.css…
--wash-subtletokens.css…
--z-popovertokens.css…

Accessibility

  • The calendar is a grid with arrow-key navigation; Esc returns focus to the field.

Do and don't

Do

  • Always let people type a date of birth; never force a calendar for it.

Don't

  • Don't mix date orders within one product.

For AI agents

This page as markdown, rendered from the same registry entry. Point an agent at it (or add .md to this page's URL), or at /llms.txt for the index.

Open date-field.md