Skip to content

Early previewhamur is not on npm yet. The components are being built in the open, follow along on GitHub.

UIComponentsReact

Date Field

A date typed in segments, month, day and year in the order of the locale, each one a spinbutton, with a button that clears them all.

Built on the headless Date Field.See its API in Docs

Rendered by React 19.3.1

date-field.tsx

Installation

npx shadcn@4.23.0 add https://hamur.dev/r/react/date-field.json

It also adds utils, button. The app needs its setup first: Installation.

Usage

Put a DateFieldInput and a DateFieldClear inside DateField, and a FieldLabel above it. Without children, DateFieldInput renders every segment, in the locale's order and styled; pass your own children to place them yourself, drawing each with DateFieldSegment. Values are ISO 8601 strings such as 2026-11-07, reported only once every segment is filled. The keys, the typing, the limits, the form value and the validity come from the headless Date Field.

import {
  DateField,
  DateFieldClear,
  DateFieldInput,
  DateFieldSegment,
} from '@/components/ui/date-field'

Examples

Default

A due date under its label, filled in, with a Clear button.

Its preview and code are at the top of the page.

The box is Input's: the same height, border, radius and focus ring, which shows while any segment holds focus, and the same ring in the destructive color while the field is invalid. The focused segment is filled as a menu item is, an empty one shows its placeholder in the muted color, and an invalid one is underlined with a dashed line. The Clear button is a ghost icon button, hidden while no segment has a value. This item takes Base UI's component ID as its slug and one name per Base UI part.

API reference

The styled parts pass every prop to the headless part they wrap and add classes. The props, data attributes and keyboard are on Date Field's API reference.