Skip to main content
PROYECTOVIVIANA

DatePicker

A date picker combines a segmented date input field with a dropdown calendar popup. Users can type a date directly into the field using the keyboard, or open the calendar to select a date visually.

Import

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

Basic Usage

A simple date picker with a label. Click the calendar icon or focus the field and press the arrow keys to interact with date segments.

Selected: None

const [selectedDate, setSelectedDate] = createSignal<DateValue | null>(null);

<DatePicker
  label="Event date"
  value={selectedDate()}
  onChange={setSelectedDate}
/>

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

With Min/Max Constraints

Restrict the selectable range by setting minValue and maxValue. The calendar popup will not allow navigation beyond these bounds, and the date segments enforce the limits.

Selected: None

const minDate = new CalendarDate(2026, 1, 1);
const maxDate = new CalendarDate(2026, 6, 30);

<DatePicker
  label="First half of 2026"
  minValue={minDate}
  maxValue={maxDate}
  value={constrainedDate()}
  onChange={setConstrainedDate}
  description="Select a date between Jan 1 and Jun 30, 2026"
/>

Disabled State

A disabled date picker cannot be interacted with. The input field and calendar button are visually muted.

<DatePicker
  label="Disabled date"
  isDisabled
  placeholderValue={new CalendarDate(2026, 3, 15)}
/>

Required with Validation

Mark the date picker as required and provide an error message for invalid states. The field displays a red border and the error text below.

<DatePicker
  label="Birth date"
  isRequired
  isInvalid
  errorMessage="Please select your birth date"
/>

Props

PropTypeDefaultDescription
labelstringLabel text displayed above the date input
valueDateValue | nullThe currently selected date (controlled)
onChange(date: DateValue | null) => voidHandler called when the selected date changes
minValueDateValueThe minimum selectable date
maxValueDateValueThe maximum selectable date
isDisabledbooleanfalseWhether the date picker is disabled
placeholderValueDateValueA placeholder date that controls the default segments shown when empty
isRequiredbooleanfalseWhether a date selection is required
isInvalidbooleanfalseWhether the date picker is in an invalid state
errorMessagestringError message displayed below the input when invalid
descriptionstringHelp text displayed below the input
size'sm' | 'md' | 'lg''md'The visual size of the date picker

Accessibility

  • Date segments are individually focusable with spinbutton role for screen readers
  • Arrow Up/Down increments or decrements the focused segment value
  • Tab moves between date segments (month, day, year)
  • The calendar popup button has an aria-label describing its purpose
  • Error messages are associated via aria-describedby for screen reader announcement
  • Required state is communicated through aria-required
  • Calendar popup traps focus and can be dismissed with Escape