Picker dialog
The modal form of a date or time picker, with confirm, dismiss and mode-toggle slots.
import { PickerDialog } from '@windmorph/react';Props
PickerDialog 22 props
The confirm button (last, at the end), e.g.
<Button variant="text">OK</Button>.The picker.
Whether the dialog is open (controlled).
Whether the dialog starts open when uncontrolled.
dateholds a date picker edge to edge with the actions below (Compose'sDatePickerDialog);timepads the content 24px under a "Select time" style title (Compose'sTimePickerDialog).Title for the time variant, e.g. "Select time".
The dismiss button, before the confirm button.
A control at the start of the actions row, e.g. the time picker's mode toggle.
Fill the window, with a close (x) icon button and a Save button at the top instead of the actions (M3: a full-screen modal date picker is recommended on compact windows).
compactdoes so below 600px wide.Icon of the full-screen close button.
How the dialog enters and leaves, as
Dialog'stransition:reveal, the M3 dialog motion (it slides down while its container grows, then the picker and the actions fade in), orscale, the original pop (a fade with a scale from 90%). Reduced motion keeps only the fades. Ignored while the dialog is full screen.How the user can close the dialog, as HTML's
<dialog closedby>:any(Escape or a press outside),closerequest(Escape only) ornone(only its actions or the app).The dialog's id (on the panel, the
dialogelement).Ref to the panel, the
dialogelement.
Events
Called when the dialog opens or closes.
Saves the picked value. With it, Enter on a day (or in a typed date) confirms and closes the dialog (the M3 date picker keyboard table), and the full-screen form gets its Save button. Called after the picker's latest value has rendered.
Text
Words the full-screen form shows and announces, with English defaults. A
LabelsProvidersets them for the whole app.Accessible name of the dialog when there's no visible title.
One of
aria-labeloraria-labelledbyis required.Id of a visible element that names the dialog.
One of
aria-labeloraria-labelledbyis required.
Goes on the outermost element, a full-window layer whose inline placement it can't move, so a layout class (
static,overflow-hidden, a transform) never hides or clips the dialog. Style the surface withclassNames.panel.Inline styles for the outermost element, with
className.Classes for each part, by slot.
The dimmed layer behind the dialog.
The dialog's surface: its colour, corners, padding and shadow.
The full-screen top row with the close and Save buttons.
The full-screen close (x) icon button.
The time picker dialog's
title("Select time").The bottom row of actions: mode toggle, dismiss and confirm buttons.
Also accepts the root element's HTML attributes (id, data-*, event handlers).
Spec status
Built to the M3 Expressive picker dialog spec. Each item of its variants and configurations links to a live example; where the M3 Expressive column of the spec differs from the original M3 one, it wins.
| Item | Status | Details |
|---|---|---|
| Modal date picker | Built | Variant · Date |
| Modal time picker | Built | Variant · Time |
| Full-screen modal date picker | Built | Configuration · Full screen |
| Close affordance and Save in full screen | Built | Configuration · Full screen |
| Mode toggle in the actions | Built | Configuration · Time |
| One dialog for both pickers | Extension | variant (date or time) covers what Compose splits into DatePickerDialog and TimePickerDialog. |
children as a function | Extension | children may be a function of { close }, so a confirm action can apply its value and close in one place. |
Modal date picker
BuiltVariant · Date
Modal time picker
BuiltVariant · Time
Full-screen modal date picker
BuiltConfiguration · Full screen
Close affordance and Save in full screen
BuiltConfiguration · Full screen
Mode toggle in the actions
BuiltConfiguration · Time
One dialog for both pickers
Extensionvariant(dateortime) covers what Compose splits intoDatePickerDialogandTimePickerDialog.
Extensionchildrenas a functionchildrenmay be a function of{ close }, so a confirm action can apply its value and close in one place.
Bundle size
Gzipped, as published: the component and the library code it imports. React, React Aria, Motion and the other dependencies aren't counted, and your bundler's minifier makes it smaller still. CI fails a change that grows it past its budget.
PickerDialog: 39.1 kB
Differences from Compose
- One component covers Compose's
DatePickerDialogandTimePickerDialogthroughvariant:dateholds the picker edge to edge with the actions below;timepads the content 24px and shows alabel-mediumtitle. - The panel is
surface-container-highwith 28px corners at elevation 3, on the dialog's scrim and motion. Date actions sit 8px apart with 8px below and 6px from the end; the time variant puts the mode toggle at the start of the actions row. - Full screen follows the M3 full-screen dialog, as
Dialogdoes: the panel fills the window onsurface-container-high(the date picker's container colour) with no corners or elevation, under a 56px row holding the close button and Save; the range picker's month list fills the height. - In a window too short for the whole dialog, or with large text, the picker scrolls between the title and the actions, which stay in view.
childrenmay be a function of{ close }, so a confirm action can apply its value and close in one place.