Common behavior
Picker behavior and forms
What DatePicker, DateRangePicker and TimePicker share: open state, popup modes, ref methods, focus events, disabled and read-only, clear button, placeholder, form values, validation and reset.
These props and behaviors are the same on DatePicker, DateRangePicker
and TimePicker.
Open state and popup
open/defaultOpen/onOpenChange(open, { source, reason }).reasonis'trigger','keyboard','focus','field','escape','outside','tab','select','apply','cancel'or'api'. To veto an open or close, controlopenand do not update it.defaultOpentakes effect after hydration: the server never renders a popup.openOnFocusopens when focus enters the field.refreceives{ element, focus(), blur(), open(), close() }.onFocus/onBlurfire once when focus enters or leaves the whole field group, popup included.popupMode: 'popover' | 'modal' | 'auto':'popover'is a top-layer popup anchored to the field;'modal'a<dialog>bottom sheet with a Close button;'auto'(default) decides when opening, in the event handler, withmatchMedia('(pointer: coarse) and (max-width: 640px)').- Keys: Alt+Down opens, Alt+Up and Escape close and return focus to the field; in popover mode Tab leaves the popup and closes it, in modal mode Tab stays inside.
Field
disabled: no tab stops, no popup.readOnly: focusable, no edits, no popup.placeholderis a watermark shown while the field is empty and not focused.clearablerenders a clear button; clearing firesonValueChange(null)withreason: 'clear'andonClear.editable={false}makes the segments read-only; a click on the field opens the popup.label,descriptionanderrorMessageare wired to the field group (aria-labelledby,aria-describedby). There is no floating label.classNameandstylego on the root; other DOM props (data-*,aria-*,title, DOM event handlers) go on the field group. There is nowidthprop: size the root withstyleor a class.size('sm' | 'md' | 'lg', default'md') sets the control to 24, 32 or 40 px tall with the Button metrics; see Theme and sizing.- Direction is inherited (
diron an ancestor) or set withdir: the popup aligns to the inline end and arrow keys mirror in RTL.
Field states, popup control and events
Open demoDisabled, read-only, placeholder, pick-only and open-on-focus pickers; a controlled popup that can veto opening; ref open, close, focus and blur; focus, view and value events; placeholderValue seeds; RTL.
- Interact with a field
Values and events
onValueChange(value, details) fires for user changes only, never for a
new value prop, so a controlled picker works with any
form library: pass value, update it in onValueChange, use onBlur and
ref.focus(). details.iso is the form value; zoned date-times also carry
details.epochMilliseconds. Instants are read in timeZone (an IANA name;
a fixed minute offset could not follow DST).
Forms
nameposts an ISO string, not the displayed text:YYYY-MM-DD,YYYY-MM,YYYY,YYYY-MM-DDTHH:mm[:ss](plus the offset whentimeZoneis given),HH:mm[:ss]. The server parses one format whatever the user's locale.- The form value is a visually hidden
<input>(nottype="hidden"), sorequiredand the custom validity (out of range, unavailable date or time) take part in constraint validation; aninvalidevent focuses the first segment. invalid,errorMessageandonInvalidintegrate with your own validation.- A form
resetrestoresdefaultValue.
Controlled form validation
Open demoCheck-in and check-out pickers bound to external form state with a cross-field rule, invalid and errorMessage, onBlur touch tracking, onInvalid from native constraint validation and ref.focus() on the first error.
Not offered
- Built-in value persistence: store the value yourself
(
localStorage, URL) and pass it asvalueordefaultValue. - Remappable keys: the keys follow the WAI-ARIA patterns.
- A popup z-index option: popups use the top layer, above every z-index.
- Lifecycle events and methods: use React effects.
API reference
The API reference for
@salmonui/calendars/date-picker,
@salmonui/calendars/date-range-picker
and @salmonui/calendars/time-picker lists
every prop, method and type.
Pickers in a form
Open demoPickers post ISO values, take part in required and range validation, and restore their default values on reset.