Mushilu-San UI

Search components

PlaygroundStorybookGitHub
Forms

Calendar

A month grid for picking a single date, with keyboard navigation.

Selector: mui-calendar

Import
import { Calendar } from '@mushilu-san/ui/forms';
PreviewCode

Loading example…

Overview

Calendar shows one month at a time. The value model holds the selected Date, and minDate and maxDate disable days outside the range. locale controls month and weekday names.

Arrow keys move the focused day, PageUp and PageDown move by month, and Home and End move to the start and end of the week. The month heading is announced politely when it changes.

When to use

  • Choosing a date where the user benefits from seeing the surrounding days.
  • Booking or scheduling, where availability is shown by range.

When not to use

  • Typing a date, or a date that is far in the past. Use a Date picker with a text field. Use Date picker instead.

Guidelines

Do

  • Set minDate and maxDate so impossible dates cannot be chosen.
  • Show the selected date as text nearby too.

Don't

  • Do not use a calendar for a date in the distant past or future where typing is faster.

Accessibility

Roles and attributes

ElementRoleNotes
month headingheading (level 2)aria-live="polite", so the new month is announced.
daybuttonaria-selected on the chosen day and aria-current="date" on today. Unavailable days are aria-disabled.

Keyboard

KeysAction
ArrowLeftArrowRightArrowUpArrowDownMove the focused day.
PageUpPageDownMove to the previous or next month.
HomeEndMove to the start or end of the week.
EnterSpaceSelect the focused day.
  • Name the calendar with a visible heading or a label on the control that contains it.

API

Calendar

Selector: mui-calendar

NameTypeDefaultDescription
minDateDate | nullnull Earliest selectable date. Days before it are disabled.
maxDateDate | nullnull Latest selectable date. Days after it are disabled.
localestring'en-US' BCP 47 locale used for month and weekday names. Default `en-US`.
disabledbooleanfalse Disables the whole calendar. Accepts attribute presence, e.g. <… disabled>.
NameTypeDefaultDescription
valueDate | nullnull Selected date, or `null` when none is chosen. Two-way bindable with `[(value)]`.

CSS parts

  • ::part(day)
  • ::part(next-btn)
  • ::part(prev-btn)
  • ::part(root)

Tokens

  • --mui-color-primary
  • --mui-color-surface
  • --mui-color-text
  • --mui-color-text-muted
  • --mui-color-focus-ring
  • --mui-touch-target