Mushilu-San UI

Search components

PlaygroundStorybookGitHub
Forms

Date picker

A button that opens a calendar panel to choose a single date.

Selector: mui-date-picker

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

Loading example…

Overview

Date picker shows the chosen date in a trigger button. Pressing it opens a calendar in a role="dialog". The value model is two-way bindable, and minDate and maxDate limit the choice.

The trigger carries aria-expanded and aria-haspopup="dialog". Escape closes the panel and returns focus to the trigger.

When to use

  • Choosing one date in a form where the calendar context helps.
  • Setting a date field with a limited range, such as a booking date.

When not to use

  • Dates that the user knows and types often, such as a birth date. A text input with a date type is faster. Use Input instead.
  • Showing a calendar that is always visible. Use the calendar. Use Calendar instead.

Guidelines

Do

  • Format the shown date for the user locale with locale.
  • Give the field a label so the purpose is clear.

Don't

  • Do not open the calendar automatically on page load.

Accessibility

Roles and attributes

ElementRoleNotes
triggerbutton (with aria-haspopup="dialog")aria-expanded follows the panel state.
paneldialogNamed "Date picker", aria-modal="true".

Keyboard

KeysAction
EnterSpaceOpens the panel on the trigger.
EscapeCloses the panel and returns focus to the trigger.
Arrow keys, PageUpPageDown, HomeEndMove through the days, as in the calendar.
  • Label the trigger with the field name, for example "Start date: 12 March 2027".

API

DatePicker

Selector: mui-date-picker

NameTypeDefaultDescription
placeholderstring'Pick a date' Text shown in the trigger when no date is chosen. Default `Pick a date`.
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 to format the date and calendar names. Default `en-US`.
disabledbooleanfalse Disables the trigger and the 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(panel)
  • ::part(root)
  • ::part(trigger)

Tokens

  • --mui-color-surface
  • --mui-color-border
  • --mui-shadow-3
  • --mui-color-focus-ring