Skip to main content

DatePicker

import { DatePicker } from '@enmovil/ui-design-system';

Lets the user pick a single date, with optional time and week display and a list of quick selections. onDateChange reports the selected date as a string in format.

Properties​

PropertyTypeRequiredDefaultAllowed valuesDescription
formatstringNo'DD-MM-YYYY''YYYY-MM-DD', 'DD/MM/YYYY', 'MM-DD-YYYY', 'YYYY/MM/DD', 'DD-MM-YYYY'Config the input field parse and format. When set format.type, it will force user input type with your input, it's only support basic format mask: YYYY, MM, DD, HH, mm, ss, SSS. Once use config mode, it must be fill with format your config.
isShowTimebooleanNofalse—Adds time selection to the picker. Off by default. Overridden by showTime when that is also set.
isAllowClearbooleanNotrue—Shows a clear icon that removes the selected date. On by default.
isShowWeekbooleanNofalse—Shows week numbers in the calendar. Off by default.
isQuickSelectionbooleanNotrue—Shows a list of quick selections (Today, Yesterday and so on) beside the calendar. On by default.
quickSelectorsQuickSelectorKey[]No——Which quick selections to show, from today, yesterday, tomorrow, dayBeforeYesterday and dayAfterTomorrow. Shows all five when absent or empty. Requires isQuickSelection.
disabledbooleanNo——Disables the picker so no date can be picked.
sizestringNo'middle''small', 'middle', 'large'Height of the picker: small, middle or large. Defaults to middle.
placeholderstringNo——Text shown while no date is selected.
showTimeboolean | SharedTimeProps<Dayjs>No——Adds time selection to the picker. Takes precedence over isShowTime.
minDateDayjsNonew Date()—Earliest date that can be picked. Defaults to today, so set it to allow past dates.
maxDateDayjsNonew Date()—Latest date that can be picked. Defaults to today, so set it to allow future dates.
Other attributes

DatePicker passes 366 further attributes through to the underlying element. They aren't part of the supported API and may change between releases, so use only the properties listed on this page.

Events​

NameSignatureWhen it fires
onDateChange((key: string) => void)Fires when a date is picked or cleared, with the formatted date string. Use this rather than onChange: passing onChange replaces the internal handler, so onDateChange stops firing.
onFocusPickerFocusEventHandlerFires when the input receives focus.
onBlurPickerFocusEventHandlerFires when the input loses focus.
onOpenChange((open: boolean) => void)Fires when the calendar popup opens or closes.
onOk((date: Dayjs) => void)Fires when the OK button is clicked. Only shown with showTime.

Children​

DatePicker does not accept children.

Type definitions​

Shapes used by the properties above.

QuickSelectorKey​

type QuickSelectorKey = | "today"
| "yesterday"
| "tomorrow"
| "dayBeforeYesterday"
| "dayAfterTomorrow";

Variants​

Loading examples…

Playground​

Change the controls to see how the properties affect the component. Values the controls don't cover come from the Date Picker Component example.

Loading playground…

Storybook​

Open DatePicker in Storybook to try every story with the full set of controls.