Date Picker

Material Design 3 modal or docked date picker and date range picker web components.

  • 5.6 KB gzipped
  • @lit-material/date-picker 0.1.0
  • Renders on the server

Example

Install

npm install @lit-material/date-picker @lit-material/tokens
import "@lit-material/date-picker";

Link @lit-material/tokens/css/index.css once per page for the colour, type and shape tokens. Install guide

API

<lit-material-date-picker>

Material Design 3 date picker — a single-date calendar, either modal (the default: a dialog built on the native <dialog> element, like lit-material-dialog — scrim, Escape-to-close, focus trap all come from the browser) or docked (the same header/calendar/actions, rendered plainly in-flow with no dialog, scrim, or open/show()/close() gating — meant to be embedded in your own layout, a card, or a popover you position yourself, the same way lit-material-navigation-drawer's standard variant is the same content as modal minus the dialog shell).

Properties

PropertyAttributeTypeDefaultDescription
variantvariantDatePickerVariant"modal"
openopenbooleanfalseWhether a modal picker is open. Ignored for docked, which is always visible in-flow.
valuevaluestring | undefinednoneThe confirmed date, as an ISO "YYYY-MM-DD" string.
minminstring | undefinednoneInclusive lower bound, as an ISO "YYYY-MM-DD" string.
maxmaxstring | undefinednoneInclusive upper bound, as an ISO "YYYY-MM-DD" string.
labellabelstring"Select date"
firstDayOfWeekfirst-day-of-weeknumber00 = Sunday (default), 1 = Monday, ...

Events

EventDescription
closemodal only: re-dispatched from the native close event, after the dialog has closed.
cancelmodal only: re-dispatched from the native cancel event. Cancelable: calling preventDefault() stops the dialog from closing.
changeFires when a date is confirmed via "OK" and value actually changed.

CSS parts

PartDescription
dialogThe native <dialog> element. Only rendered for modal.
containerThe visible card.
headerThe label + selected-date headline.
navThe month navigation row (or the year-range label, in year mode).
calendarThe <table role="grid"> of day cells.
year-gridThe scrollable grid of years, in year mode.
actionsThe Cancel/OK row.

Source on GitHub npm