Skip to main content
Back to Home

Date Picker

An accessible date picker component with calendar view and full keyboard navigation. Implements the ARIA grid pattern with support for min/max dates and disabled dates.

Basic Usage

Select a date using the calendar interface or keyboard navigation.

import { useState } from 'react';
import { AccessibleDatePicker } from '@a13y/react';

function Example() {
  const [date, setDate] = useState<Date | null>(null);

  return (
    <AccessibleDatePicker
      label="Select a date"
      value={date}
      onChange={setDate}
    />
  );
}

With Date Constraints

Restrict selectable dates with minDate and maxDate props.

const today = new Date();
const nextMonth = new Date();
nextMonth.setMonth(nextMonth.getMonth() + 1);

<AccessibleDatePicker
  label="Select a date"
  value={date}
  onChange={setDate}
  minDate={today}
  maxDate={nextMonth}
/>

Props

NameTypeDefaultDescription
label*string-Label for the date picker
value*Date | null-Selected date value
onChange*(date: Date | null) => void-Callback fired when date selection changes
minDateDate-Minimum selectable date
maxDateDate-Maximum selectable date
disabledDatesDate[]-Array of dates that cannot be selected
localestring'en-US'Locale for date formatting
disabledbooleanfalseDisable the date picker
classNamestring-Optional CSS class

Keyboard Navigation

Arrow KeysNavigate between days
Space/EnterSelect focused date
HomeFirst day of week
EndLast day of week
Page UpPrevious month
Page DownNext month

Accessibility Features

  • ✓Implements ARIA grid pattern with role="grid"
  • ✓Full keyboard navigation with arrow keys, Home, End, Page Up/Down
  • ✓Current date and selected date clearly announced via aria-label
  • ✓Disabled dates marked with aria-disabled
  • ✓Month/year selection controls properly labeled