Search
MaterialComponentsDocs
Components overviewApp barBadgeButtonsButton groupButtonExtended FABFAB menuFABIcon buttonSplit buttonCardCarouselCheckboxChipsDate & time pickersDate pickerTime pickerDialogDividerListLoading & progressLoading indicatorProgressMenuNavigationNavigation barNavigation drawerNavigation railRadio buttonsSearchSelectSheetsBottom sheetSide sheetSliderSnackbarSwitchTabsText fieldToolbarTooltip

Date picker

Choose a date or enter one by keyboard. Explore calendar and input modes, ranges, and selection limits.

FactoryWeb ComponentsReactVueSvelteSolidJS
PublishedUpdated

A date picker lets people select a date, or a range of dates. M3 has four forms: a docked calendar under its field, a modal dialog, a modal date input for typing, and a full-screen picker, for compact screens and the usual form of a range.

Usage

The picker is a text field with a calendar button, which opens the calendar. In the dialog forms a selection is a draft until OK (or Save); Cancel, Close, Escape and the scrim discard it. change fires once a date is committed; dates before minDate or after maxDate cannot be chosen.

Vanilla
import { createDatePicker } from 'material';

const datePicker = createDatePicker({
  label: 'Departure',
  variant: 'modal',
  value: '2026-10-02',
  minDate: '2026-10-01',
});
datePicker.on('change', ({ value: date }) => search(date));
document.body.append(datePicker.element);
Web Components
<m-datepicker value="2026-10-02" variant="modal" min="2026-10-01" label="Departure"></m-datepicker>

<script type="module">
  const datepicker = document.querySelector('m-datepicker');
  datepicker.addEventListener('change', (event) => search(event.detail.date));
</script>
React
import { useState } from 'react';
import { Datepicker } from 'material/react';
import { search } from './app';

export function Example() {
  const [value, setValue] = useState("2026-10-02");
  return (
    <Datepicker value={value} onChange={(event) => { setValue(event.detail.value); search(event.detail.date); }} variant="modal" min="2026-10-01" label="Departure" />
  );
}
Vue
<script setup lang="ts">
import { ref } from 'vue';
import { MDatepicker } from 'material/vue';
import { search } from './app';

const value = ref("2026-10-02");
</script>

<template>
  <MDatepicker v-model="value" @change="search($event.detail.date)" variant="modal" min="2026-10-01" label="Departure" />
</template>
Svelte
<script lang="ts">
  import { Datepicker } from 'material/svelte';
  import { search } from './app';

  let value = $state("2026-10-02");
</script>

<Datepicker bind:value onchange={(event) => search(event.detail.date)} variant="modal" min="2026-10-01" label="Departure" />
SolidJS
import { createSignal } from 'solid-js';
import { Datepicker } from 'material/solid';
import { search } from './app';

export function Example() {
  const [value, setValue] = createSignal("2026-10-02");
  return (
    <Datepicker value={value()} onChange={(event) => { setValue(event.detail.value); search(event.detail.date); }} variant="modal" min="2026-10-01" label="Departure" />
  );
}

Examples

A range, full screen

With selectionMode: 'range', the first tap is the start and the second the end, and Save commits both. A lone date given as the value is the one-day range.

Vanilla
import { createDatePicker } from 'material';

const datePicker = createDatePicker({
  label: 'Stay',
  variant: 'fullscreen',
  selectionMode: 'range',
  value: ['2026-10-02', '2026-10-05'],
});
document.body.append(datePicker.element);
Web Components
<m-datepicker value="2026-10-02/2026-10-05" variant="fullscreen" selection-mode="range" label="Stay"></m-datepicker>
React
import { useState } from 'react';
import { Datepicker } from 'material/react';

export function Example() {
  const [value, setValue] = useState("2026-10-02/2026-10-05");
  return (
    <Datepicker value={value} onChange={(event) => setValue(event.detail.value)} variant="fullscreen" selectionMode="range" label="Stay" />
  );
}
Vue
<script setup lang="ts">
import { ref } from 'vue';
import { MDatepicker } from 'material/vue';

const value = ref("2026-10-02/2026-10-05");
</script>

<template>
  <MDatepicker v-model="value" variant="fullscreen" selection-mode="range" label="Stay" />
</template>
Svelte
<script lang="ts">
  import { Datepicker } from 'material/svelte';

  let value = $state("2026-10-02/2026-10-05");
</script>

<Datepicker bind:value variant="fullscreen" selectionMode="range" label="Stay" />
SolidJS
import { createSignal } from 'solid-js';
import { Datepicker } from 'material/solid';

export function Example() {
  const [value, setValue] = createSignal("2026-10-02/2026-10-05");
  return (
    <Datepicker value={value()} onChange={(event) => setValue(event.detail.value)} variant="fullscreen" selectionMode="range" label="Stay" />
  );
}

Typing a date

modal-input opens on the keyboard entry, in dateFormat. The field rejects a date that does not exist (02/30) or falls outside the limits, and OK stays disabled until the entry is valid. The pencil and calendar buttons switch between typing and the calendar.

Vanilla
import { createDatePicker } from 'material';

const datePicker = createDatePicker({ label: 'Birthday', variant: 'modal-input', dateFormat: 'DD/MM/YYYY' });
document.body.append(datePicker.element);
Web Components
<m-datepicker variant="modal-input" date-format="DD/MM/YYYY" label="Birthday"></m-datepicker>
React
import { Datepicker } from 'material/react';

export function Example() {
  return (
    <Datepicker variant="modal-input" dateFormat="DD/MM/YYYY" label="Birthday" />
  );
}
Vue
<script setup lang="ts">
import { MDatepicker } from 'material/vue';
</script>

<template>
  <MDatepicker variant="modal-input" date-format="DD/MM/YYYY" label="Birthday" />
</template>
Svelte
<script lang="ts">
  import { Datepicker } from 'material/svelte';
</script>

<Datepicker variant="modal-input" dateFormat="DD/MM/YYYY" label="Birthday" />
SolidJS
import { Datepicker } from 'material/solid';

export function Example() {
  return (
    <Datepicker variant="modal-input" dateFormat="DD/MM/YYYY" label="Birthday" />
  );
}

locale (<m-datepicker locale>, default 'en-US') sets the BCP 47 locale tag for month and weekday names, the first day of the week, Home/End row navigation, and the default field format when dateFormat is omitted (editable fields use Gregorian dates and Latin digits so displayed values round-trip through input parsing).

Read-only

A read-only field keeps its value readable and focusable, as a native readonly input does, and its calendar closed.

Vanilla
import { createDatePicker } from 'material';

const datePicker = createDatePicker({
  label: 'Check-in',
  value: '2026-10-02',
  readOnly: true,
  supportingText: 'Set by your booking',
});
document.body.append(datePicker.element);
Web Components
<m-datepicker value="2026-10-02" label="Check-in" supporting-text="Set by your booking" readonly></m-datepicker>
React
import { useState } from 'react';
import { Datepicker } from 'material/react';

export function Example() {
  const [value, setValue] = useState("2026-10-02");
  return (
    <Datepicker value={value} onChange={(event) => setValue(event.detail.value)} label="Check-in" supportingText="Set by your booking" readonly />
  );
}
Vue
<script setup lang="ts">
import { ref } from 'vue';
import { MDatepicker } from 'material/vue';

const value = ref("2026-10-02");
</script>

<template>
  <MDatepicker v-model="value" label="Check-in" supporting-text="Set by your booking" readonly />
</template>
Svelte
<script lang="ts">
  import { Datepicker } from 'material/svelte';

  let value = $state("2026-10-02");
</script>

<Datepicker bind:value label="Check-in" supportingText="Set by your booking" readonly />
SolidJS
import { createSignal } from 'solid-js';
import { Datepicker } from 'material/solid';

export function Example() {
  const [value, setValue] = createSignal("2026-10-02");
  return (
    <Datepicker value={value()} onChange={(event) => setValue(event.detail.value)} label="Check-in" supportingText="Set by your booking" readonly />
  );
}

With required, checkValidity() answers whether a date is missing, and reportValidity() also marks the field invalid; the web component reports it to its form as valueMissing. The factory's specialDates marks dates, or makes them unselectable, each with an optional tooltip.

Months swipe horizontally, by touch, trackpad or mouse wheel, and the arrows slide the same way. Tapping the year opens every year from minDate to maxDate (1900 to 2100 without limits). Full screen, the months are one vertical list that grows as it scrolls.

Deferred calendar

createDeferredDatePicker from material/components/datepicker/deferred is an opt-in entry with the same DatePickerConfig and DatePickerComponent contract:

import { createDeferredDatePicker } from 'material/components/datepicker/deferred';
import 'material/styles/datepicker';

const deferredPicker = createDeferredDatePicker({ label: 'Departure', variant: 'modal' });
document.body.append(deferredPicker.element);

The field and trigger are built immediately. With code splitting enabled, the calendar chunk loads on the first open, or earlier on pointerenter or focus on the trigger. isOpen() and the open/close state and events remain synchronous. Until the calendar arrives, aria-expanded stays false and a modal dialog takes its name from label through aria-label; focus enters the calendar only when ready. A close() while loading keeps it closed when the chunk lands. A failed calendar import closes a waiting open and emits loaderror with the error; a later open may try again, though browsers may cache the rejected module URL, so recovery can require a page reload.

API

Options

variant

The form: inline under the field, a dialog, a dialog opened on date entry, or the whole screen

Type'docked' | 'modal' | 'modal-input' | 'fullscreen'
Default'docked'
selectionMode

One date, or a start and an end

Type'single' | 'range'
Default'single'
value

The initial value; in range mode a pair, and a lone date the one-day range [d, d]

TypeDate | string | [start, end] | { start, end }
Defaultundefined
label

The field's label, and the dialog's title

Typestring
Default'Select date'
minDate / maxDate

The first and last selectable dates

TypeDate | string
Defaultundefined
locale

BCP 47 locale tag driving month and weekday names, the first day of the week, and the default dateFormat when omitted (<m-datepicker locale>)

Typestring
Default'en-US'
dateFormat

How the field shows and reads dates (YYYY, MM, M, DD, D, MMM, MMMM)

Typestring
Default'MM/DD/YYYY' (or from locale)
placeholder

The field's placeholder

Typestring
Defaultthe format
initialView

The view the calendar opens on (not in full screen)

Type'day' | 'month' | 'year'
Default'day'
closeOnSelect

Commit and close on a selection, without OK

Typeboolean
Defaultfalse
specialDates

Dates to mark, or to make unselectable

Type{ date, highlight?, disabled?, tooltip? }[]
Default[]
disabled

Whether the field starts disabled

Typeboolean
Defaultfalse
readOnly

The value shows and cannot change: no typing, the calendar does not open, the calendar button is disabled

Typeboolean
Defaultfalse
required

A date is required: set on the input for forms, and read by checkValidity()

Typeboolean
Defaultfalse
supportingText

The supporting text under the field; without it, the date format

Typestring
Defaultthe format
name

The field's name, for forms

Typestring
Defaultundefined
animate

Whether the dialog fades in

Typeboolean
Defaulttrue
class

Additional CSS classes

Typestring
Defaultundefined
prefix

Prefix for CSS class names

Typestring
Default'mtrl'

Methods

open() / close()

Shows or hides the calendar

ReturnsDatePickerComponent
isOpen()

Whether the calendar is open

Returnsboolean
getValue() / setValue(value)

The committed value; setValue takes what value does

ReturnsDate | null ([Date, Date] | null in range mode) / DatePickerComponent
getFormattedValue()

The value as the field shows it

Returnsstring
clear()

Clears the value

ReturnsDatePickerComponent
setMinDate(date) / setMaxDate(date)

The limits

ReturnsDatePickerComponent
enable() / disable()

Disabled state

ReturnsDatePickerComponent
setReadOnly(readOnly) / isReadOnly()

Read-only state

ReturnsDatePickerComponent / boolean
setRequired(required)

Whether a date is required

ReturnsDatePickerComponent
checkValidity() / reportValidity()

False when a required date is missing; reportValidity() also shows the error on the field

Returnsboolean
setSupportingText(text)

The supporting text; null or '' shows the format again

ReturnsDatePickerComponent
calendar.goToDate(date) / nextMonth() / prevMonth() / nextYear() / prevYear()

Moves the calendar without selecting

Returnsvoid
calendar.showDayView() / showMonthView() / showYearView() / getCurrentView()

The view

Returnsvoid / string
on(event, handler) / off(event, handler)

Events

ReturnsDatePickerComponent
destroy()

Removes the picker

Returnsvoid

Events

change

The committed value changed: value as getValue() returns it, rangeEndDate a range's end (null otherwise), iso the value as ISO text

Payload{ value, rangeEndDate, formattedValue, iso }
open / close

The calendar opened or closed

Payload{ value }
loaderror

A deferred calendar chunk failed to load; a later open may try again

Payload{ error }

Every change has the same shape, whether the calendar, the field or setValue() committed it; a docked range emits once, when both its dates are chosen. The web component's change carries { value, date }: value as an ISO date, YYYY-MM-DD, a range as YYYY-MM-DD/YYYY-MM-DD, and empty as '', and date the Date form. So the factory's value is a Date and its iso the text, while the web component's value is the text and its date the Date.

Styling

.mtrl-datepicker { }                     /* the field and its calendar */
.mtrl-datepicker__calendar { }           /* the dialog */
.mtrl-datepicker--docked, .mtrl-datepicker--modal, .mtrl-datepicker--fullscreen, .mtrl-datepicker--range { }
.mtrl-datepicker__modal-header, .mtrl-datepicker__title, .mtrl-datepicker__headline { }
.mtrl-datepicker__track { }              /* the swiping months */
.mtrl-datepicker__list, .mtrl-datepicker__subhead { }  /* full screen */
.mtrl-datepicker__days, .mtrl-datepicker__weekday, .mtrl-datepicker__cell, .mtrl-datepicker__day { }
.mtrl-datepicker__day--today, .mtrl-datepicker__day--selected, .mtrl-datepicker__cell--range { }
.mtrl-datepicker__years, .mtrl-datepicker__year, .mtrl-datepicker__months, .mtrl-datepicker__month { }
.mtrl-datepicker__footer, .mtrl-datepicker__cancel, .mtrl-datepicker__confirm, .mtrl-datepicker__close, .mtrl-datepicker__save { }

Measurements

From the M3 date picker specs and their tokens:

Attribute Value
Field Fills its container up to 360dp; 280dp where it shrinks to fit, as the text field (Compose TextFieldDefaults.MinWidth)
Modal 360dp wide, surface-container-high, 28dp corners, elevation 3, a 0.32 scrim
Header 120dp (128dp for a range); title Label Large, headline Headline Large (Title Large for a range)
Full screen The viewport, no corners or elevation, a 128dp header with close (x) and Save, subheads Title Small
Weekdays and days 48dp cells, Body Large; a 40dp round selection
Selected primary with on-primary text; today has a 1dp primary outline
Range A 40dp secondary-container band, continuous across visible adjacent-month days including endpoints; outside-month text stays muted
Years 3 columns, 72 × 36dp items
Motion The months slide; the dialog fades in