Skip to main content
PROYECTOVIVIANA

DateField

A date field allows users to type a date value using individually editable segments for month, day, and year. Each segment can be incremented or decremented with arrow keys, making it efficient for keyboard-driven date entry.

Import

import { DateField } from '@proyecto-viviana/solid-spectrum';
import { CalendarDateClass as CalendarDate } from '@proyecto-viviana/solid-stately';

Basic Usage

A simple date field with a label. Click on a segment and use arrow keys or type numbers to set the date.

Birth date

Entered date: None

const [date, setDate] = createSignal<DateValue | null>(null);

<DateField
  label="Birth date"
  value={date()}
  onChange={setDate}
/>

<p>Selected: {date()?.toString() ?? "None"}</p>

With Placeholder Value

A placeholder date controls the initial segments shown when the field is empty. This helps guide users toward a reasonable date. The placeholder is displayed in a muted style.

Event date
Enter the date of your event
<DateField
  label="Event date"
  placeholderValue={new CalendarDate(2026, 6, 15)}
  description="Enter the date of your event"
/>

Disabled State

A disabled date field cannot be interacted with. All segments are visually muted and not focusable.

Locked date
<DateField
  label="Locked date"
  isDisabled
  value={new CalendarDate(2026, 2, 17)}
/>

Required with Validation

Mark the field as required and display an error message for invalid states.

Start date 
A start date is required
<DateField
  label="Start date"
  isRequired
  isInvalid
  errorMessage="A start date is required"
/>

Props

PropTypeDefaultDescription
labelstring—Label text displayed above the date input
valueDateValue | null—The currently entered date (controlled)
onChange(date: DateValue | null) => void—Handler called when the date value changes
isDisabledbooleanfalseWhether the date field is disabled
isRequiredbooleanfalseWhether a date value is required
placeholderValueDateValue—A placeholder date that sets the initial segments displayed when empty
isInvalidbooleanfalseWhether the date field is in an invalid state
errorMessagestring—Error message displayed below the input when invalid
descriptionstring—Help text displayed below the input
minValueDateValue—The minimum allowed date
maxValueDateValue—The maximum allowed date
size'sm' | 'md' | 'lg''md'The visual size of the date field

Accessibility

  • Each date segment uses a spinbutton role with proper aria-valuemin, aria-valuemax, and aria-valuenow
  • Arrow Up/Down increments or decrements the focused segment
  • Tab moves focus between segments (month, day, year)
  • Typing digits automatically advances to the next segment when complete
  • Label is associated via aria-labelledby for screen reader announcement
  • Error messages are linked through aria-describedby
  • Required state is communicated through aria-required