JGuang

DatePicker

DatePicker · Arco Design

Preview
npm install @arco-design/web-react@2.66.18

DatePicker

Choose a date. Support year, month, week, day type, support range selection, etc.

Install

npm install @arco-design/web-react@2.66.18

Import @arco-design/web-react/dist/css/arco.css at the entry and set the locale with ConfigProvider. React 19 projects must also import @arco-design/web-react/es/_util/react-19-adapter first, or imperative APIs such as Message and Modal cannot render.

Examples

  • Basic: The basic usage of DatePicker.
  • Status: date inputter in different states
  • Prefix: Set the prefix via the prefix property
  • MonthPicker: The basic usage of MonthPicker.
  • YearPicker: The basic usage of the YearPicker.
  • WeekPicker: The basic usage of WeekPicker.
  • QuarterPicker: The basic usage of QuarterPicker.
  • DatePicker showTime: Use showTime to select a date with time.
  • RangePicker: The basic usage of RangePicker.
  • defaultValue: DatePicker has a default value.
  • disabled date: Use disabledDate to disable specified dates. 2.5.0 starts to support disabledTime to disable time, which needs to be used with showTime.
  • Shortcuts: Use shortcuts to preset time for quick selection.
  • Custom shortcuts position: Use shortcutsPlacementLeft to place the shortcuts to the left.
  • Dynamic control range: According to the selected value to control the selected range, use onSelect and disabledDate. If showTime is set, the comparison dimension needs to be converted to day.
  • Size: Setting size can use four sizes (mini small default large). The height corresponds to 24px, 32px, 36px, 40px.
  • Extra footer: Add an extra footer to meet the needs of some customized information.
  • Disabled: Disabled.
  • Customize cell: Use dateRender to customize date cells.
  • Under Control: value and onChange should be used together,
  • Customize trigger element: Customize trigger element.
  • Panel Only: Only use panel, hide input selection.
  • UTC: Use utcOffset to set the UTC time. Note: When using UTC or time zonetime, use timestamp or Date object when passing value. Strings cannot represent unique time, which will cause trouble.
  • Timezone: Use timezone to set timezone, if set the utcOffset, utcOffset takes effect. Note: When using UTC or time zonetime, use timestamp or Date object when passing value. Strings cannot represent unique time, which will cause trouble.

Examples come from the official Arco Design repository (MIT) at the commit published as npm 2.66.18. Some use online images or upload endpoints; network requests are disabled in previews.

API

picker are shared by all types

Picker Props

PropertyDescriptionTypeDefaultValueVersion
allowClearAllow Clearbooleantrue-
editableWhether input box can be entered.booleantrue-
errorWhether the textarea is error.(Deprecated, removed in the next major version, use status='error' instead)boolean--
hideNotInViewDatesThe panel hides gray dates that are not in the current time rangeboolean-2.20.0
popupVisibleWhether the popup is visible or notboolean--
shortcutsPlacementLeftThe preset range selection is placed on the left side of the panel for a large number of scenes with preset time.boolean--
unmountOnExitWhether to destroy popup when hiddenboolean--
utcOffsetSet the timezone offset, set to 0 if utc time is required.number--
timezonetimezone name, if utcOffset is set, utcOffset takes effect.string--
positionThe position of the popup'top' | 'tl' | 'tr' | 'bottom' | 'bl' | 'br'--
sizeThe size of input box'mini' | 'small' | 'default' | 'large'default-
statusStatus'error' | 'warning'-2.45.0
extraExtra footerReactNode--
prefixprefixReactNode-2.43.0
separatorSeparator symbol in the range selector input boxReactNode--
triggerElementTrigger element.ReactNode-2.9.0
classNameAdditional css classstring | string[]--
dayStartOfWeekThe first day of the week starts on the day of the week, 0-Sunday, 1-Monday, and so on.0 | 1 | 2 | 3 | 4 | 5 | 6-2 - 6 in 2.20.0
defaultPickerValueDefault displayed date of panelCalendarValue--
disabledWhether to disableboolean | boolean[]--
iconsIcon configuration of panel.{prev?: ReactNode;prevDouble?: ReactNode;next?: ReactNode;nextDouble?: ReactNode;inputSuffix?: ReactNode;}-2.20.0
inputPropsNative input attributesReact.InputHTMLAttributes<HTMLInputElement>-2.60.0
localeInternationalization configuration.Record<string, any>--
pickerValueDisplayed date of panel.CalendarValue-2.9.0
placeholderThe placeholder of date inputstring | string[]--
shortcutsShortcut selection of preset time rangeShortcutType[]--
styleAdditional styleCSSProperties--
triggerPropsThe props of the Trigger component.Partial<TriggerProps>--
dateRenderCustomize the contents of the date cell.(currentDate: Dayjs) => ReactNode--
disabledDateSpecify the date that cannot be selected(current: Dayjs) => boolean--
getPopupContainerThe parent node of the popup(node: HTMLElement) => Elementbl-
onChangeCallback when the selected value changes(dateString: string, date: Dayjs) => void--
onClearCallback when clicking the clear button() => void--
onOkCallback when click confirm button(dateString: string, date: Dayjs) => void--
onPickerValueChangeCallback when date of panel changes.(dateString: string, value: Dayjs) => void-2.9.0
onSelectCallback when the show date changes but the selected value does not change(dateString: string, date: Dayjs) => void--
onSelectShortcutCallback when click shortcut selection.(shortcut: ShortcutType) => void--
onVisibleChangeCallback when the visibility of the popup is changed(visible?: boolean) => void--
panelRenderCustomize the panel node.(panelNode: ReactNode) => ReactNode-2.34.0

DatePicker

type CalendarValue = number | string | Date | Dayjs。

PropertyDescriptionTypeDefaultValue
showNowBtnWhen displaying showTime, button to select current time.booleantrue
defaultValueTo set default dateCalendarValue-
showTimeWhether to show time selectionboolean | TimePickerProps-
timepickerPropsParameters of TimePicker, refer to TimePickerProps, which has the same function as showTime.TimePickerProps-
valueTo set dateCalendarValue-
disabledTimeSpecify the time that cannot be selected(current?: Dayjs) => DisabledTimeProps-
formatDate format, refer to dayjs. When using a string, manual editing is allowed. When using (value: Dayjs) => string, value must be picked from Picker.string | ((value: Dayjs) => string)YYYY-MM-DD

WeekPicker

PropertyDescriptionTypeDefaultValue
formatDate format, refer to dayjsstringgggg-wo
defaultValueTo set default dateCalendarValue-
valueTo set dateCalendarValue-

MonthPicker

PropertyDescriptionTypeDefaultValue
formatDate format, refer to dayjsstringYYYY-MM
defaultValueTo set default dateCalendarValue-
valueTo set dateCalendarValue-

YearPicker

PropertyDescriptionTypeDefaultValue
formatDate format, refer to dayjsstringYYYY
defaultValueTo set default dateCalendarValue-
valueTo set dateCalendarValue-

QuarterPicker

PropertyDescriptionTypeDefaultValue
formatDate format, refer to dayjsstringYYYY-[Q]Q
defaultValueTo set default dateCalendarValue-
valueTo set dateCalendarValue-

RangePicker

PropertyDescriptionTypeDefaultValueVersion
clearRangeOnReselectWhen reselect the range, the previous range will be cleared for next selectionboolean-2.23.0
disabledTimeSpecify the time that cannot be selected(current: Dayjs, type: 'start' | 'end') => DisabledTimeProps--
modeThe type of RangePicker'date' | 'month' | 'week' | 'year' | 'quarter'date-
onSelectCallback when the show value changes but the selected value does not change(dateString: string[], value: Dayjs[], extra: { type: 'start' | 'end' }) => void-extra in 2.23.0
triggerElementTrigger element.ReactNode-2.9.0
defaultPickerValueDefault displayed date of panel.CalendarValue[]--
defaultValueTo set default dateCalendarValue[]--
disabledWhether to disable input boxboolean | boolean[]--
formatDate format, refer to dayjsstring | string[]YYYY-MM-DDstring[] in 2.55.0
inputPropsNative input attributesReact.InputHTMLAttributes<HTMLInputElement>[]-2.60.0
pickerValueDisplayed date of panel.CalendarValue[]-2.9.0
placeholderThe placeholder of inputstring[]--
showTimeWhether to show time selection, if an object is passed in, the parameters will be passed to the built-in TimePicker.boolean | TimePickerRangeProps--
timepickerPropsParameters of TimePicker, refer to TimePickerProps, which has the same function as showTime.TimePickerProps--
valueTo set dateCalendarValue[]--
onChangeCallback when the selected value changes(dateString: string[], date: Dayjs[]) => void--
onOkCallback when click confirm button(dateString: string[], date: Dayjs[]) => void--
onPickerValueChangeCallback when date of panel changes.(dateString: string[], value: Dayjs[]) => void-2.9.0

ShortcutType

export type ShortcutType = {
  text: ReactNode;
  value: () => Dayjs | Dayjs[];
} & Record<string, any>;

CalendarValue

export type CalendarValue = number | string | Date | Dayjs;

TimePickerProps

export type TimePickerProps = BaseTimePickerProps & PickerProps;

DisabledTimeProps

export type DisabledTimeProps = {
  disabledHours?: () => number[];
  disabledMinutes?: () => number[];
  disabledSeconds?: () => number[];
};

TimePickerRangeProps

export type TimePickerRangeProps = Omit<TimePickerProps, "defaultValue"> & {
  defaultValue?: CalendarValue[];
};