0.1.0-rc.2

Date Field

Date fields capture a single calendar date with locale-aware formatting and an optional calendar popup for pointer input.

Try it

Usage

Compose the input, calendar trigger, popup, and calendar as children of RuiDateField. When no children are supplied, RuiDateField renders this same composition for you. Bind value as an ISO YYYY-MM-DD string and use dateStyle to control the formatted value.

import {
  RuiDateField,
  RuiDateFieldCalendar,
  RuiDateFieldControl,
  RuiDateFieldInput,
  RuiDateFieldPopover,
  RuiDateFieldToggle,
} from '@ecopages/radiant-ui/date-field';
import { RuiField } from '@ecopages/radiant-ui/field';
import { RuiLabel } from '@ecopages/radiant-ui/label';
 
<RuiField name="startDate">
  <RuiLabel>Start date</RuiLabel>
  <RuiDateField value="2026-08-07" dateStyle="medium">
    <RuiDateFieldControl>
      <RuiDateFieldInput />
      <RuiDateFieldToggle />
    </RuiDateFieldControl>
    <RuiDateFieldPopover>
      <RuiDateFieldCalendar />
    </RuiDateFieldPopover>
  </RuiDateField>
</RuiField>

Calendar input

Use the calendar button to choose a date instead of typing. When the popup opens, focus moves to the selected date or the first available date. This example uses a two-month popup for dates near a month boundary.

Masked entry

masked guides segment-by-segment typing. Disable it when users paste full ISO strings from external tools.

Bound the range

Set min and max to prevent invalid bookings. The embedded calendar inherits the same constraints.

Theming

Date Field surfaces map to semantic surface roles, never Tailwind palette steps:

PartCSS roles
Control group (rui-date-field__group)border, background, radius-control; focus-ring ring on focus-within
Input texton-background, --text-control, --space-control-*
Placeholderon-surface + opacity-muted
Disabledopacity-disabled
Invalid (aria-invalid)error border
Popup (rui-date-field__popover)popover surface + shadow-overlay (via rui-popover)

Geometry shares control tokens (--size-control-*, --radius-control, --space-control-*) with RuiInput and RuiButton so form rows align. Override at the theme layer, not in component CSS.

API

RuiDateField is a custom element (<rui-date-field>) that coordinates its light-DOM input, toggle button, and calendar popover.

Attributes

AttributeTypeDefaultDescription
valuestring''Canonical ISO YYYY-MM-DD value.
minstring''Earliest selectable ISO date.
maxstring''Latest selectable ISO date.
disabledbooleanfalseDisable the field and calendar.
read-onlybooleanfalseDisable editing while keeping the value visible.
labelstring''Accessible name when there is no associated RuiLabel.
namestring''Native name for the underlying input.
placeholderstringlocale defaultOverrides the locale-derived placeholder.
localestring''BCP 47 locale tag, or comma-separated fallback list.
date-styleshort · medium · long · fullmediumHow the committed value is displayed when not editing.
maskedbooleantrueGuide digits with a locale mask while typing.
visible-monthsnumber1Month grids shown in the calendar popover.

Events

EventDetailDescription
rui-change{ value }Fired when a valid date is committed (typing or calendar pick).

Composition helpers

Pass these helpers as RuiDateField children when the default structure is not enough:

HelperRenders
RuiDateFieldControlBordered control row containing the input and trigger.
RuiDateFieldInputLocale-aware text input managed by the date-field host.
RuiDateFieldToggleButton that opens and closes the calendar popup.
RuiDateFieldPopoverPopup shell for the calendar.
RuiDateFieldCalendarRuiCalendar synchronized with the field value and constraints.

CSS classes

Public BEM classes on the composed light-DOM surface (documented via @cssclass on RuiDateField):

ClassDescription
.rui-date-fieldRoot surface.
.rui-date-field__groupBordered control-height row wrapping input and toggle.
.rui-date-field__inputThe masked / formatted text input.
.rui-date-field__popoverCalendar popup shell (rui-popover / rui-floating).

Theme roles

PartCSS variables consumed
Control group--border, --background, --radius-control, --focus-ring
Input text--on-background, --text-control, --space-control-x, --space-control-y
Placeholder--on-surface, --opacity-muted
Disabled--opacity-disabled
Invalid--error
Popup--shadow-overlay (via rui-popover)

Accessibility

  • Pair every date field with a visible RuiLabel or aria-label.
  • Invalid dates should surface through RuiField error text, not color alone.
  • The trigger opens the popup and moves focus to the selected date or first available date; arrow keys move between days, Page Up / Page Down change months, and Escape closes the popup.