Skip to content

Material 3

Components

Date picker

Date pickers let people select a date, or a range of dates.

9:30

Select date

Aug 17, 2025

August 2025

27
28
29
30
31
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
1
2
3
4
5
6

Date pickers let people select a date, or a range of dates, on a calendar or by typing it. Compose a DatePicker from its parts, and use a DateRangePicker to select a range of dates. The pickers have no built-in text: write the text of each part yourself, in your language.

To let people type a date without a calendar, use a date field.

import {
  DatePicker,
  DatePickerCalendar,
  DatePickerContent,
  DatePickerDialog,
  DatePickerHeader,
  DatePickerHeadline,
  DatePickerInput,
  DatePickerModeToggle,
  DateRangePicker,
  DateRangePickerCalendar,
  DateRangePickerHeadline,
  DateRangePickerInput,
  DialogTrigger,
} from '@material-web/react'
import { parseDate } from '@internationalized/date'
import { Heading } from 'react-aria-components'

Basic date picker

Write the parts of a DatePicker as its children, with their text. A picker is shown where it is written, and does not open on its own: to show it in a dialog, see Modal date picker.

Select date

Aug 17, 2025

August 2025

27
28
29
30
31
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
1
2
3
4
5
6
import { parseDate } from '@internationalized/date'
import {
  DatePicker,
  DatePickerCalendar,
  DatePickerContent,
  DatePickerHeader,
  DatePickerHeadline,
  DatePickerInput,
  DatePickerModeToggle,
} from '@material-web/react'
import { Heading } from 'react-aria-components'

export default function Basic() {
  return (
    <DatePicker defaultValue={parseDate('2025-08-17')}>
      {({ displayMode }) => (
        <>
          <DatePickerHeader>
            <Heading slot="title">Select date</Heading>
            <DatePickerHeadline>
              {displayMode === 'picker' ? 'Selected date' : 'Entered date'}
            </DatePickerHeadline>
            <DatePickerModeToggle
              aria-label={
                displayMode === 'picker' ? 'Switch to text input mode' : 'Switch to calendar mode'
              }
            />
          </DatePickerHeader>
          <DatePickerContent>
            <DatePickerCalendar />
            <DatePickerInput label="Date" />
          </DatePickerContent>
        </>
      )}
    </DatePicker>
  )
}

A DatePicker selects one date, and a DateRangePicker a range of dates. Show either one in the page, as in the example above, or in a dialog:

To showUse
A picker in a dialogA DatePickerDialog around the picker, with its buttons
A range pickerA DateRangePicker, in the page or in a DatePickerDialog
A full-screen range pickerA DateRangePicker in a dialog with isFullScreen

Composition

A DatePicker is composed of these parts. It holds a DatePickerHeader and, under it, a DatePickerContent, which hold the others:

PartInUse
DatePickerHeaderDatePickerThe header
Heading with slot="title"DatePickerHeaderThe title
DatePickerHeadlineDatePickerHeaderShows the selected date, or its children while no date is selected
DatePickerModeToggleDatePickerHeaderThe button that switches between the calendar and the date input
DatePickerContentDatePickerThe content, under the header
DatePickerCalendarDatePickerContentThe calendar
DatePickerInputDatePickerContentThe date input. Set its label to label its field.

Leave out the mode toggle, the calendar or the input to do without it. This picker has the calendar alone:

Select date

Aug 17, 2025

August 2025

27
28
29
30
31
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
1
2
3
4
5
6
import { parseDate } from '@internationalized/date'
import {
  DatePicker,
  DatePickerCalendar,
  DatePickerContent,
  DatePickerHeader,
  DatePickerHeadline,
} from '@material-web/react'
import { Heading } from 'react-aria-components'

export default function CalendarOnly() {
  return (
    <DatePicker defaultValue={parseDate('2025-08-17')}>
      <DatePickerHeader>
        <Heading slot="title">Select date</Heading>
        <DatePickerHeadline>Selected date</DatePickerHeadline>
      </DatePickerHeader>
      <DatePickerContent>
        <DatePickerCalendar />
      </DatePickerContent>
    </DatePicker>
  )
}

The DatePickerCalendar is a calendar, and the DatePickerInput is a date field. Set their props on the picker. The props of React Aria's Calendar, or of its RangeCalendar on a DateRangePicker, apply to the calendar, and the value, the bounds and the disabled, read-only and invalid states apply to the input too. A DatePicker does not take visibleDuration.

Date range picker

Use a DateRangePicker to select a range of dates, such as the dates of a flight or of a hotel stay. Compose it the same way, with these parts in place of the headline, the calendar and the input:

PartUse
DateRangePickerHeadlineShows the selected range, or one end of it, or its children while neither end is selected
DateRangePickerCalendarShows the months in a scrolling column
DateRangePickerInputHolds the start and end inputs. Set startLabel and endLabel to label their fields.

The picker fills the height it is given: in this example, the height of the box it is in. Press two days to select a range.

Select dates

Start date – End date

September 2024 to August 2026

27
28
29
30
31
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
1
2
3
4
5
6
import { parseDate } from '@internationalized/date'
import {
  DatePickerContent,
  DatePickerHeader,
  DatePickerModeToggle,
  DateRangePicker,
  DateRangePickerCalendar,
  DateRangePickerHeadline,
  DateRangePickerInput,
} from '@material-web/react'
import { Heading } from 'react-aria-components'

export default function Range() {
  return (
    <div className="flex h-140 flex-col">
      <DateRangePicker defaultFocusedValue={parseDate('2025-08-17')}>
        {({ displayMode }) => (
          <>
            <DatePickerHeader>
              <Heading slot="title">Select dates</Heading>
              <DateRangePickerHeadline>
                {displayMode === 'picker' ? 'Start date – End date' : 'Enter dates'}
              </DateRangePickerHeadline>
              <DatePickerModeToggle
                aria-label={
                  displayMode === 'picker' ? 'Switch to text input mode' : 'Switch to calendar mode'
                }
              />
            </DatePickerHeader>
            <DatePickerContent>
              <DateRangePickerCalendar />
              <DateRangePickerInput startLabel="Start date" endLabel="End date" />
            </DatePickerContent>
          </>
        )}
      </DateRangePicker>
    </div>
  )
}

In a DatePickerDialog, the months fill the dialog's height above the buttons. In this example, the confirm button is disabled until a range is selected.

import { parseDate } from '@internationalized/date'
import {
  Button,
  DatePickerContent,
  DatePickerDialog,
  DatePickerHeader,
  DatePickerModeToggle,
  DateRangePicker,
  DateRangePickerCalendar,
  DateRangePickerHeadline,
  DateRangePickerInput,
  DialogTrigger,
  Icon,
  type DatePickerRenderProps,
} from '@material-web/react'
import { useState } from 'react'
import { Heading, type DateValue, type RangeValue } from 'react-aria-components'

const parts = ({ displayMode }: DatePickerRenderProps) => (
  <>
    <DatePickerHeader>
      <Heading slot="title">Select dates</Heading>
      <DateRangePickerHeadline>
        {displayMode === 'picker' ? 'Start date – End date' : 'Enter dates'}
      </DateRangePickerHeadline>
      <DatePickerModeToggle
        aria-label={
          displayMode === 'picker' ? 'Switch to text input mode' : 'Switch to calendar mode'
        }
      />
    </DatePickerHeader>
    <DatePickerContent>
      <DateRangePickerCalendar />
      <DateRangePickerInput startLabel="Start date" endLabel="End date" />
    </DatePickerContent>
  </>
)

export default function RangeModal() {
  const [dates, setDates] = useState<RangeValue<DateValue> | null>({
    start: parseDate('2025-08-17'),
    end: parseDate('2025-08-23'),
  })
  const [picked, setPicked] = useState(dates)
  return (
    <DialogTrigger onOpenChange={(isOpen) => isOpen && setPicked(dates)}>
      <Button variant="outlined">
        <Icon name="date_range" />
        {dates ? `${dates.start.toString()} – ${dates.end.toString()}` : 'Pick the dates'}
      </Button>
      <DatePickerDialog
        clearButton={
          <Button variant="text" onPress={() => setPicked(null)}>
            Clear
          </Button>
        }
        dismissButton={
          <Button variant="text" slot="close">
            Cancel
          </Button>
        }
        confirmButton={
          <Button variant="text" slot="close" isDisabled={!picked} onPress={() => setDates(picked)}>
            OK
          </Button>
        }
      >
        <DateRangePicker value={picked} onChange={setPicked} autoFocus>
          {parts}
        </DateRangePicker>
      </DatePickerDialog>
    </DialogTrigger>
  )
}

To show a picker in a dialog, put it in a DatePickerDialog. Pass the dialog's buttons as confirmButton and dismissButton, and add a clearButton if you want one. Open the dialog from your own button with a DialogTrigger, or with the dialog's isOpen.

The picker reports every selection through onChange. To keep the date unchanged until it is confirmed, hold the picked date in your own state and save it in the confirm button's onPress.

A button with slot="close" closes the dialog after its own onPress. Escape and a press outside the dialog close it too. Set isDismissable={false} to keep a press outside from closing it, and isKeyboardDismissDisabled to keep Escape from closing it.

import { parseDate } from '@internationalized/date'
import {
  Button,
  DatePicker,
  DatePickerCalendar,
  DatePickerContent,
  DatePickerDialog,
  DatePickerHeader,
  DatePickerHeadline,
  DatePickerInput,
  DatePickerModeToggle,
  DialogTrigger,
  Icon,
  type DatePickerRenderProps,
} from '@material-web/react'
import { useState } from 'react'
import { Heading, type DateValue } from 'react-aria-components'

const parts = ({ displayMode }: DatePickerRenderProps) => (
  <>
    <DatePickerHeader>
      <Heading slot="title">Select date</Heading>
      <DatePickerHeadline>
        {displayMode === 'picker' ? 'Selected date' : 'Entered date'}
      </DatePickerHeadline>
      <DatePickerModeToggle
        aria-label={
          displayMode === 'picker' ? 'Switch to text input mode' : 'Switch to calendar mode'
        }
      />
    </DatePickerHeader>
    <DatePickerContent>
      <DatePickerCalendar />
      <DatePickerInput label="Date" />
    </DatePickerContent>
  </>
)

export default function Modal() {
  const [date, setDate] = useState<DateValue | null>(parseDate('2025-08-17'))
  const [picked, setPicked] = useState(date)
  return (
    <DialogTrigger onOpenChange={(isOpen) => isOpen && setPicked(date)}>
      <Button variant="outlined">
        <Icon name="calendar_today" />
        {date ? date.toString() : 'Pick a date'}
      </Button>
      <DatePickerDialog
        clearButton={
          <Button variant="text" onPress={() => setPicked(null)}>
            Clear
          </Button>
        }
        dismissButton={
          <Button variant="text" slot="close">
            Cancel
          </Button>
        }
        confirmButton={
          <Button variant="text" slot="close" isDisabled={!picked} onPress={() => setDate(picked)}>
            OK
          </Button>
        }
      >
        <DatePicker value={picked} onChange={setPicked} autoFocus>
          {parts}
        </DatePicker>
      </DatePickerDialog>
    </DialogTrigger>
  )
}
  • The dialog places the dismiss button and then the confirm button at the end, under the picker, and the clear button at the start.
  • The Heading in the title slot of the picker's DatePickerHeader names the dialog.
  • Set autoFocus on the picker to focus a day of the calendar, or the first segment of the input, when the dialog opens.
  • The dialog opens and closes with the same props as a dialog.

Slots

  1. title
SlotChildUse
titleA HeadingThe picker's title. In a DatePickerDialog, it names the dialog.

Dialog

  1. close
SlotChildUse
closeAny button, such as the confirm and dismiss buttonsCloses the DatePickerDialog after its own onPress

Controlled

Pass dates as CalendarDate objects from @internationalized/date, in value, defaultValue, minValue and maxValue. Set the initial date with defaultValue, or control it with value and onChange. onChange is called with the date when a day is selected or a date is typed, and with null while the input holds no date that can be selected.

Select date

Aug 17, 2025

August 2025

27
28
29
30
31
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
1
2
3
4
5
6
2025-08-17, picker
import { parseDate } from '@internationalized/date'
import {
  DatePicker,
  DatePickerCalendar,
  DatePickerContent,
  DatePickerHeader,
  DatePickerHeadline,
  DatePickerInput,
  DatePickerModeToggle,
  type DatePickerDisplayMode,
} from '@material-web/react'
import { useState } from 'react'
import { Heading, type DateValue } from 'react-aria-components'

export default function Controlled() {
  const [value, setValue] = useState<DateValue | null>(parseDate('2025-08-17'))
  const [displayMode, setDisplayMode] = useState<DatePickerDisplayMode>('picker')
  return (
    <div className="flex flex-col gap-space-200">
      <DatePicker
        value={value}
        onChange={setValue}
        displayMode={displayMode}
        onDisplayModeChange={setDisplayMode}
      >
        <DatePickerHeader>
          <Heading slot="title">Select date</Heading>
          <DatePickerHeadline>No date</DatePickerHeadline>
          <DatePickerModeToggle
            aria-label={
              displayMode === 'picker' ? 'Switch to text input mode' : 'Switch to calendar mode'
            }
          />
        </DatePickerHeader>
        <DatePickerContent>
          <DatePickerCalendar />
          <DatePickerInput label="Date" />
        </DatePickerContent>
      </DatePicker>
      <span className="px-space-300 text-body-md text-on-surface-variant">
        {value ? value.toString() : 'null'}, {displayMode}
      </span>
    </div>
  )
}

The value of a DateRangePicker is a { start, end } pair of dates. Its onChange is called with the range once both ends are selected or typed, and with null while the inputs hold one end or none.

Display mode

The display mode is picker (the default), which shows the calendar, or input, which shows the date input. Set the initial mode with defaultDisplayMode, or control it with displayMode and onDisplayModeChange, which is called when the mode toggle switches the mode.

Pass a function as the picker's children to write text that follows the display mode, such as the mode toggle's aria-label. It is called with { displayMode }.

Each time the input is shown, it holds the selected date, or the ends of the range, or nothing: a date that was partly typed, or that could not be selected, is cleared. Each time the calendar is shown, it opens at the month of the selected date, or of the start of the range. With no date selected, it stays on the month it showed before.

Show the input first for a date in the distant past or future, such as a date of birth. In this example, defaultFocusedValue sets the month the calendar opens at while no date is selected.

Date of birth

Entered date

January 1990

31
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
1
2
3
import { parseDate } from '@internationalized/date'
import {
  DatePicker,
  DatePickerCalendar,
  DatePickerContent,
  DatePickerHeader,
  DatePickerHeadline,
  DatePickerInput,
  DatePickerModeToggle,
} from '@material-web/react'
import { Heading } from 'react-aria-components'

export default function InputFirst() {
  return (
    <DatePicker defaultDisplayMode="input" defaultFocusedValue={parseDate('1990-01-01')}>
      {({ displayMode }) => (
        <>
          <DatePickerHeader>
            <Heading slot="title">Date of birth</Heading>
            <DatePickerHeadline>
              {displayMode === 'picker' ? 'Selected date' : 'Entered date'}
            </DatePickerHeadline>
            <DatePickerModeToggle
              aria-label={
                displayMode === 'picker' ? 'Switch to text input mode' : 'Switch to calendar mode'
              }
            />
          </DatePickerHeader>
          <DatePickerContent>
            <DatePickerCalendar />
            <DatePickerInput label="Date of birth" />
          </DatePickerContent>
        </>
      )}
    </DatePicker>
  )
}

Month and year pickers

In the calendar, the month and year button opens a grid of years over the month, scrolled to the year shown. Shift+M and Shift+Y move the focus to the button. Escape in the years closes the years alone, not what is around the picker.

Clearing the value

Set the value to null to clear it: no day is selected, the input is empty, and the headline shows its children. A picker has no clear button of its own. In a DatePickerDialog, pass one as clearButton, as in the modal date picker.

Form props

Set isDisabled to disable a picker: its days, its month and year button and its input are dimmed and cannot be pressed or focused, and the selected day is not marked in the calendar. Set isReadOnly to keep the date as it is: the days and the input can be focused, but a press or a key changes nothing. The headline and the mode toggle stay as they are.

Disabled

Aug 17, 2025

August 2025

27
28
29
30
31
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
1
2
3
4
5
6

Read-only

Aug 17, 2025

August 2025

27
28
29
30
31
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
1
2
3
4
5
6
import { parseDate } from '@internationalized/date'
import {
  DatePicker,
  DatePickerCalendar,
  DatePickerContent,
  DatePickerHeader,
  DatePickerHeadline,
  DatePickerInput,
  DatePickerModeToggle,
  type DatePickerRenderProps,
} from '@material-web/react'
import { Heading } from 'react-aria-components'

const parts =
  (title: string) =>
  ({ displayMode }: DatePickerRenderProps) => (
    <>
      <DatePickerHeader>
        <Heading slot="title">{title}</Heading>
        <DatePickerHeadline>
          {displayMode === 'picker' ? 'Selected date' : 'Entered date'}
        </DatePickerHeadline>
        <DatePickerModeToggle
          aria-label={
            displayMode === 'picker' ? 'Switch to text input mode' : 'Switch to calendar mode'
          }
        />
      </DatePickerHeader>
      <DatePickerContent>
        <DatePickerCalendar />
        <DatePickerInput label="Date" />
      </DatePickerContent>
    </>
  )

export default function FormProps() {
  const date = parseDate('2025-08-17')
  return (
    <>
      <DatePicker defaultValue={date} isDisabled>
        {parts('Disabled')}
      </DatePicker>
      <DatePicker defaultValue={date} isReadOnly>
        {parts('Read-only')}
      </DatePicker>
    </>
  )
}

Note: A picker takes no name. To include a date in a form, use a date field.

Validation

Set minValue and maxValue to limit the dates that can be selected. Days outside them are dimmed, and the previous and next buttons and the years stop at them. Pass isDateUnavailable to mark days as unavailable: they are struck out, and can be focused with the keyboard but not selected.

A typed date that is outside the bounds or unavailable stays in the input, marked as invalid, and makes the value null until a valid date replaces it.

Select a weekday

Aug 18, 2025

August 2025

27
28
29
30
31
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
1
2
3
4
5
6
import { isWeekend, parseDate } from '@internationalized/date'
import {
  DatePicker,
  DatePickerCalendar,
  DatePickerContent,
  DatePickerHeader,
  DatePickerHeadline,
  DatePickerInput,
  DatePickerModeToggle,
} from '@material-web/react'
import { Heading, useLocale } from 'react-aria-components'

export default function Bounds() {
  const { locale } = useLocale()
  return (
    <DatePicker
      defaultValue={parseDate('2025-08-18')}
      minValue={parseDate('2025-08-11')}
      maxValue={parseDate('2025-10-31')}
      isDateUnavailable={(date) => isWeekend(date, locale)}
    >
      {({ displayMode }) => (
        <>
          <DatePickerHeader>
            <Heading slot="title">Select a weekday</Heading>
            <DatePickerHeadline>
              {displayMode === 'picker' ? 'Selected date' : 'Entered date'}
            </DatePickerHeadline>
            <DatePickerModeToggle
              aria-label={
                displayMode === 'picker' ? 'Switch to text input mode' : 'Switch to calendar mode'
              }
            />
          </DatePickerHeader>
          <DatePickerContent>
            <DatePickerCalendar />
            <DatePickerInput label="Date" />
          </DatePickerContent>
        </>
      )}
    </DatePicker>
  )
}

Typed ranges

  • A typed date that is outside the bounds, unavailable, or on the wrong side of the other end is not accepted. It stays in its input, marked as invalid, and the range is null until a valid date replaces it.
  • When the two dates are out of order, the one typed last is marked as invalid, with no error text.
  • For the end date, isDateUnavailable is called with the start date as its anchor. Unless you set allowsNonContiguousRanges, an end date after the next unavailable day is not accepted.
  • The inputs accept only dates within the months of the calendar: its visibleDuration, which is 24 months by default, around the range or today. The months move when the keyboard focus goes past either end.

Full-screen

For a full-screen range picker, as on a phone, put the DateRangePicker in a dialog with isFullScreen, under your own bar that holds a close button and a Save button. A picker is 360dp wide: give it className="w-full" to fill the dialog. The days of each week then spread evenly across its width, and the months scroll to the bottom edge of the window.

import { parseDate } from '@internationalized/date'
import {
  AppBar,
  Button,
  DatePickerContent,
  DatePickerHeader,
  DatePickerModeToggle,
  DateRangePicker,
  DateRangePickerCalendar,
  DateRangePickerHeadline,
  DateRangePickerInput,
  Dialog,
  DialogTrigger,
  Icon,
  IconButton,
  type DatePickerRenderProps,
} from '@material-web/react'
import { useState } from 'react'
import { Heading, type DateValue, type RangeValue } from 'react-aria-components'

const parts = ({ displayMode }: DatePickerRenderProps) => (
  <>
    <DatePickerHeader>
      <Heading slot="title">Select dates</Heading>
      <DateRangePickerHeadline>
        {displayMode === 'picker' ? 'Start date – End date' : 'Enter dates'}
      </DateRangePickerHeadline>
      <DatePickerModeToggle
        aria-label={
          displayMode === 'picker' ? 'Switch to text input mode' : 'Switch to calendar mode'
        }
      />
    </DatePickerHeader>
    <DatePickerContent>
      <DateRangePickerCalendar />
      <DateRangePickerInput startLabel="Start date" endLabel="End date" />
    </DatePickerContent>
  </>
)

export default function FullScreen() {
  const [dates, setDates] = useState<RangeValue<DateValue> | null>({
    start: parseDate('2025-08-17'),
    end: parseDate('2025-08-23'),
  })
  const [picked, setPicked] = useState(dates)
  return (
    <DialogTrigger onOpenChange={(isOpen) => isOpen && setPicked(dates)}>
      <Button variant="outlined">
        <Icon name="date_range" />
        {dates ? `${dates.start.toString()} – ${dates.end.toString()}` : 'Pick the dates'}
      </Button>
      <Dialog isFullScreen className="bg-surface-container-high pb-0">
        {({ state }) => (
          <>
            <AppBar className="bg-surface-container-high">
              <IconButton slot="leading" aria-label="Close" onPress={() => state.close()}>
                <Icon name="close" />
              </IconButton>
              <Button
                slot="trailing"
                variant="text"
                isDisabled={!picked}
                onPress={() => {
                  setDates(picked)
                  state.close()
                }}
              >
                Save
              </Button>
            </AppBar>
            <DateRangePicker value={picked} onChange={setPicked} className="w-full">
              {parts}
            </DateRangePicker>
          </>
        )}
      </Dialog>
    </DialogTrigger>
  )
}

Text and locale

The pickers have no built-in text. Write it in the parts: the title, the headline shown while no date is selected, the mode toggle's aria-label, the inputs' labels, and the text of the dialog's buttons. A part with no text shows none, but the mode toggle requires an aria-label.

The pickers format the dates for the locale: the headline's date or range, the month and year, the days of the week, and the input's segments and format. The previous and next buttons are named in the locale too (Previous and Next in English). To set a locale, wrap the picker in an I18nProvider from react-aria-components.

The locale also sets the calendar system (th-TH is Buddhist, ja-JP-u-ca-japanese has eras), the first day of the week, the names and digits of the days, months and years, and the direction the arrow keys move. The input's own error texts, such as Value must be 09/01/2025 or later., are in the browser's language, not the locale's. See Date field.

Sélectionner une date

17 août 2025

août 2025

28
29
30
31
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import { parseDate } from '@internationalized/date'
import {
  DatePicker,
  DatePickerCalendar,
  DatePickerContent,
  DatePickerHeader,
  DatePickerHeadline,
  DatePickerInput,
  DatePickerModeToggle,
} from '@material-web/react'
import { Heading, I18nProvider } from 'react-aria-components'

export default function Locale() {
  return (
    <I18nProvider locale="fr-FR">
      <DatePicker defaultValue={parseDate('2025-08-17')}>
        {({ displayMode }) => (
          <>
            <DatePickerHeader>
              <Heading slot="title">Sélectionner une date</Heading>
              <DatePickerHeadline>
                {displayMode === 'picker' ? 'Date sélectionnée' : 'Date saisie'}
              </DatePickerHeadline>
              <DatePickerModeToggle
                aria-label={
                  displayMode === 'picker'
                    ? 'Passer à la saisie au clavier'
                    : 'Passer au calendrier'
                }
              />
            </DatePickerHeader>
            <DatePickerContent>
              <DatePickerCalendar />
              <DatePickerInput label="Date" />
            </DatePickerContent>
          </>
        )}
      </DatePicker>
    </I18nProvider>
  )
}
  • A DatePickerDialog is laid out in the locale's direction, unless you set its dir.
  • A picker or a calendar outside a dialog follows the page's dir. Make it agree with the locale, so that the days run in the direction the arrow keys move.
  • To change the calendar system, choose it in the locale (th-TH-u-ca-gregory). createCalendar changes the calendar but not the input.

Customization

Pass classes in className to restyle a picker: they apply to its outermost element, as style and ref do. A DatePickerHeader, a DatePickerContent and a DatePickerModeToggle take className too. See Styling for the classes, the states and the theme.

  • Width: A picker is 360dp wide. Give it className="w-full" to fill the element that holds it.
  • Height: A DateRangePicker fills the height it is given, and its months scroll in it.
  • Months: A DateRangePicker holds 24 months. Set visibleDuration for more or fewer, as in visibleDuration={{ months: 12 }}.
  • Calendar: To compose your own calendar, use the parts of the calendar. Its Layout section shows how DatePickerCalendar composes them.