@zephinax/react-datepicker-calendar

API reference

Props, value shapes, and behaviors for DatePicker and Calendar.

Components and modes

  • DatePicker: input + calendar popper with managed open/close behavior.
  • Calendar: bare calendar grid for inline embedding.

The selection mode is inferred from the value shape you pass:

  • Single: Day | null
  • Range: { from: Day | null; to: Day | null }
  • Multi: Day[]

Day is { year: number; month: number; day: number }.

Behavior notes

  • DatePicker closes after a single selection or after both from and to are set for ranges.
  • Disabled days or out-of-range dates call onDisabledDayError and keep the current value.
  • minimumDate / maximumDate affect both navigation (arrows, month/year selectors) and clickability.
  • Keyboard: Arrow keys move focus across days; Enter selects; Tab cycles through focusable controls.

Shared props (DatePicker and Calendar)

PropTypeNotesDefault
valueDay | Day[] | { from: Day | null; to: Day | null }Controls mode; malformed shapes throw.null
onChange(nextValue) => voidReceives the updated selection.required
disabledDaysDay[]Exact days users cannot pick.[]
onDisabledDayError(day: Day) => voidInvoked when a disabled/out-of-range day is attempted.noop
minimumDate / maximumDateDayClamps navigation and selection.null
selectorStartingYear / selectorEndingYearnumberLimits year selector; defaults to today - 100 to today + 50.0 (auto)
shouldHighlightWeekendsbooleanWeekend styling follows locale weekDays.false
colorPrimary / colorPrimaryLightstringAccent colors mapped to CSS vars.#d24670 / #edadc0
slideAnimationDurationstringDuration for header/grid transitions (e.g., 0.4s).0.4s
locale'en' | 'fa' | Locale objectDrives language, numbering, calendar system, direction, weekends.'en'
calendarClassNamestringExtra class on the calendar root.''
calendarTodayClassNamestringApplied to today when not selected.undefined
calendarSelectedDayClassNamestringSingle/multi selected days.undefined
calendarRangeStartClassName / calendarRangeEndClassName / calendarRangeBetweenClassNamestringRange edge and in-between styling.undefined
customDaysClassName{ year: number; month: number; day: number; className: string }[]Per-day classes (holidays, events).[]
renderFooter() => ReactNodeFooter area inside the calendar.() => null

DatePicker-only props

PropTypeNotesDefault
inputPlaceholderstringFallbacks to locale defaultPlaceholder when empty.''
inputClassNamestringExtra class on the input element.''
inputNamestringPassed to the input name attribute.''
formatInputText() => stringWhen truthy, overrides the built-in formatted value.() => {}
renderInput({ ref }) => ReactNodeFully replace the input; forward ref to keep focus/blur logic.() => null
wrapperClassNamestringClass on the outer DatePicker wrapper.''
calendarPopperPosition'auto' | 'top'Allow flipping or force the popper above the input.'auto'

CSS hooks

  • Variables: --cl-color-primary, --cl-color-primary-light, --animation-duration.
  • Class hooks: today/selected/range classes and customDaysClassName for per-day overrides.
  • Structure: wrapperClassName (DatePicker root) and calendarClassName (calendar root) let you integrate with your design system without rewriting the base CSS.

Locale helpers

utils(locale?) exposes locale-aware helpers:

  • getToday(), getMonthName(month), getMonthNumber(name), getMonthLength({ year, month })
  • getMonthFirstWeekday(date) honors locale week start
  • isBeforeDate(day1, day2) and checkDayInDayRange({ day, from, to })
  • getLanguageDigits(value) for locale-specific digit rendering

On this page