Date Input

Date Input

mm
dd
yyyy
mm
dd
yyyy
––
AM
mm
dd
yyyy
––
––
AM
mm
dd
yyyy
––
––
––
AM

DateInput is a component that allows users to enter and edit date and time values using a keyboard. Each part of a date value is displayed in an individually editable segment.

API Reference

DateInput Props

PropertyTypeDescriptionDefault
labelReactNode | CalendarDate | CalendarDateTime | undefined| nullThe content to display as the label.-
valueDateValueThe current value of the date input (controlled).-
defaultValuestring | undefinedThe default value of the date input (uncontrolled).-
placeholderValueDateValueA placeholder time that influences the format of the placeholder shown when no value is selected. Defaults current date at midnight.-
minValueDateValueThe minimum allowed date that a user may select.-
maxValueDateValueThe maximum allowed date that a user may select.-
localestringThe locale to display and edit the value according to.-
errorMessageReactNode | (v: ValidationResult) => ReactNodeAn error message for the date input.-
startContentReactNodeElement to be rendered in the left side of the date input.-
endContentReactNodeElement to be rendered in the right side of the date input.-
isRequiredbooleanWhether user input is required on the input before form submission.false
isReadOnlybooleanWhether the input can be selected but not changed by the user.-
isDisabledbooleanWhether the input is disabled.false
isInvalidbooleanWhether the input value is invalid.false
createCalendar(name: string) => CalendarA function that creates a Calendar object for a given calendar identifier.-
isDateUnavailable(date: DateValue) => booleanCallback that is called for each date of the calendar. If it returns true, then the date is unavailable.-
autoFocusbooleanWhether the element should receive focus on render.false
hourCycle12 | 24Whether to display the time in 12 or 24 hour format. This is determined by the user's locale.-
granularityday | hour | minute | secondDetermines the smallest unit that is displayed in the date picker. Typically "day" for dates.-
hideTimeZonebooleanWhether to hide the time zone abbreviation.false
shouldForceLeadingZerosbooleanWhether to always show leading zeros in the month, day, and hour fields.true
classNamesInputClassNamesClassName for each components in the Input-
stylesInputStylesStyles for each components in the Input-

DateInput Events

AttributeTypeDescription
onFocus(e: FocusEvent<Target>) => voidHandler that is called when the element receives focus.
onBlur(e: FocusEvent<Target>) => voidHandler that is called when the element loses 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.
onChange(value: MappedTimeValue<TimeValue>) => voidHandler that is called when the value changes.

Usage

To use the DateInput component, import it from the library and include it in your JSX code:

import { DateInput } from 'react-calendar-kit';
 
<DateInput />;