Skip to content

Events#

TypeDescription
onChangefunction(optional) Will be called on a date change event. Returns an object. See Returned Object below.
onTypefunction(optional) Will be called on every input and date picker interaction. Returns an object. See Returned Object below.
onSubmitfunction(optional) Will be called once a user presses the submit button.
onCancelfunction(optional) Will be called once a user presses the cancel button.
onResetfunction(optional) Will be called once a user presses the reset button. The date picker will revert to the value it had when first rendered. If no initial value was provided, the date is cleared.
onOpenfunction(optional) Will be called once date-picker is visible.
onClosefunction(optional) Will be called once date-picker is hidden.
onDaysRenderfunction(optional) Will be called before the days of each calendar view are rendered, and again on interactions such as hover and selection. Receives the days array and the calendar number (0 for the first calendar, 1 for the second in range mode). Change the day objects, or return a new array, to customize the days. See Manipulate the days in the calendar view.
onFocusfunction(optional) Will be called once the input gets focus.
onBlurfunction(optional) Will be called once the input loses focus.
onKeyDown(event: React.KeyboardEvent<HTMLElement>) => void(optional) Will be called when a key is pressed while the date input has focus. Call event.preventDefault() to keep the key from being typed, e.g. to set the date with a keyboard shortcut. Check event.metaKey and event.ctrlKey to leave browser shortcuts alone.
onKeyUp(event: React.KeyboardEvent<HTMLElement>) => void(optional) Will be called when a key is released while the date input has focus.

Returned Object#

The type of native event will depend on the interaction. All additional HTML attributes will be returned as well.

{
date: null | 'date as `returnFormat` | `yyyy-MM-dd`', /* Available if `range` is `false` */
startDate: null | 'date as `returnFormat` | `yyyy-MM-dd`', /* Available if `range` is `true` */
endDate: null | 'date as `returnFormat` | `yyyy-MM-dd`', /* Available if `range` is `true` */
invalidDate: null | 'date as `returnFormat` | `yyyy-MM-dd`', /* Available if `range` is `false` */
invalidStartDate: null | 'date as `returnFormat` | `yyyy-MM-dd`', /* Available if `range` is `true` */
invalidEndDate: null | 'date as `returnFormat` | `yyyy-MM-dd`', /* Available if `range` is `true` */
isValid: boolean, /* Available if `range` is `false` */
isValidStartDate: boolean, /* Available if `range` is `true` */
isValidEndDate: boolean, /* Available if `range` is `true` */
daysBetween: number, /* Available if `range` is `true` */
attributes: { attributes },
event: null | { native event }
}
Suggest an edit