DatePicker

Allow users to select a Date and Time value.

Props#

DatePicker#

PropTypeDefaultDescription
arrowPaddingnumber8The padding required to prevent the arrow from reaching the very edge of the popper.
arrowShadowColorstringThe `box-shadow` of the popover arrow
arrowSizenumberThe size of the popover arrow
autoFocusbooleanWhether the element should receive focus on render.
boundaryHTMLElement | "clippingParents" | "scrollParent"clippingParentsThe boundary area for the popper. Used within the preventOverflow modifier
childrenstring | number | bigint | boolean | ReactElement<any, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal | Promise<...> | ((props: { ... }) => ReactNode)The content of the popover. It is usually the PopoverTrigger, and PopoverContent
closeDelaynumber200Delay in milliseconds before the popover closes after a trigger event. Only works when `trigger="hover"`
closeOnBlurbooleantrueIf true, the popover will close when you blur out it by clicking outside or tabbing out
closeOnEscbooleantrueIf true, the popover will close when you hit the Esc key
closeOnSelectboolean
computePositionOnMountbooleanIf true, the popover will be positioned when it mounts (even if it's not open) Note 🚨: We don't recommend using this in a popover/menu intensive UI or page as it might affect scrolling performance.
createCalendar(name: string) => Calendar
defaultIsOpenbooleanIf true, the popover will be initially opened.
defaultOpenbooleanWhether the overlay is open by default (uncontrolled).
defaultValueDateValue
descriptionstring | number | bigint | boolean | ReactElement<any, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal | Promise<...>A description for the field. Provides a hint such as specific requirements for what to choose.
direction"ltr" | "rtl"ltrTheme direction ltr or rtl. Popper's placement will be set accordingly
errorMessagestring | number | bigint | boolean | ReactElement<any, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal | Promise<...> | ((v: ValidationResult) => ReactNode)An error message for the field.
eventListenerstype ONLY_FOR_FORMAT = | boolean | { scroll?: boolean | undefined resize?: boolean | undefined }trueIf provided, determines whether the popper will reposition itself on scroll and resize of the window.
flipbooleantrueIf true, the popper will change its placement and flip when it's about to overflow its boundary area.
granularityGranularityDetermines the smallest unit that is displayed in the date picker. By default, this is `"day"` for dates, and `"minute"` for times.
gutternumber8The distance or margin between the reference and popper. It is used internally to create an offset modifier. NB: If you define offset prop, it'll override the gutter.
hideTimeZonebooleanfalseWhether to hide the time zone abbreviation.
hourCycle12 | 24Whether to display the time in 12 or 24 hour format. By default, this is determined by the user's locale.
idstringThe html id attribute of the popover. If not provided, we generate a unique id. This id is also used to auto-generate the `aria-labelledby` and `aria-describedby` attributes that points to the PopoverHeader and PopoverBody
isDateUnavailable(date: DateValue) => booleanCallback that is called for each date of the calendar. If it returns true, then the date is unavailable.
isDisabledbooleanWhether the input is disabled.
isInvalidbooleanWhether the input value is invalid.
isLazybooleanPerformance 🚀: If true, the PopoverContent rendering will be deferred until the popover is open.
isOpenbooleanWhether the overlay is open by default (controlled).
isReadOnlybooleanWhether the input can be selected but not changed by the user.
isRequiredbooleanWhether user input is required on the input before form submission.
labelstring | number | bigint | boolean | ReactElement<any, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal | Promise<...>The content to display as the label.
lazyBehaviorLazyModeunmountPerformance 🚀: The lazy behavior of popover's content when not visible. Only works when `isLazy={true}` - "unmount": The popover's content is always unmounted when not open. - "keepMounted": The popover's content initially unmounted, but stays mounted when popover is open.
localestring
matchWidthbooleanfalseIf true, the popper will match the width of the reference at all times. It's useful for autocomplete, `date-picker` and select patterns.
maxValueDateValue
minValueDateValue
modifiersPartial<Modifier<string, any>>[]Array of popper.js modifiers. Check the docs to see the list of possible modifiers you can pass.
offset[number, number]The main and cross-axis offset to displace popper element from its reference element.
onBlur(e: FocusEvent<Element, Element>) => voidHandler that is called when the element loses focus.
onChange(value: DateValue | null) => void
onClose() => voidCallback fired when the popover closes
onFocus(e: FocusEvent<Element, Element>) => voidHandler that is called when the element receives focus.
onFocusChange(isFocused: boolean) => voidHandler that is called when the element's focus status changes.
onKeyDown(e: KeyboardEvent) => voidHandler that is called when a key is pressed.
onKeyUp(e: KeyboardEvent) => voidHandler that is called when a key is released.
onOpen() => voidCallback fired when the popover opens
onOpenChange(isOpen: boolean) => voidHandler that is called when the overlay's open state changes.
openDelaynumber200Delay in milliseconds before the popover opens after a trigger event. Only works when `trigger="hover"`
pageBehaviorPageBehaviorvisibleControls the behavior of paging. Pagination either works by advancing the visible page by visibleDuration (default) or one unit of visibleDuration.
placeholderValueDateValueA placeholder date that influences the format of the placeholder shown when no value is selected. Defaults to today's date at midnight.
placementPlacementWithLogicalbottomThe placement of the popper relative to its reference.
preventOverflowbooleantrueIf true, will prevent the popper from being cut off and ensure it's visible within the boundary area.
returnFocusOnClosebooleantrueIf true, focus will be returned to the element that triggers the popover when it closes
shouldForceLeadingZerosbooleanWhether to always show leading zeros in the month, day, and hour fields. By default, this is determined by the user's locale.
strategy"fixed" | "absolute"absoluteThe CSS positioning strategy to use.
timeZonestring
trigger"click" | "hover"clickThe interaction that triggers the popover. hover - means the popover will open when you hover with mouse or focus with keyboard on the popover trigger click - means the popover will open on click or press Enter to Space on keyboard
validate( value: DateValue, ) => true | ValidationError | null | undefinedA function that returns an error message if a given value is invalid. Validation errors are displayed to the user when the form is submitted if `validationBehavior="native"`. For realtime validation, use the isInvalid prop instead.
validationBehavior"aria" | "native"'aria'Whether to use native HTML form validation to prevent form submission when the value is missing or invalid, or mark the field as required or invalid via ARIA.
validationStateValidationState
valueDateValue

Was this helpful?