Date Picker

Date pickers allow users to select a date from a calendar.

import {
DatePicker,
DatePickerLabel,
DatePickerInput,
DatePickerCalendar,
} from '@cerberus/react'

Usage

The DatePicker component is a controlled component that allows users to select a single date or a range of dates. It consists of a label, input field, and a calendar view.

Single Date Picker

Date Range Picker

To create a date range picker, set the selectionMode prop to range on the DatePicker component and use the RangePickerInput component as the input field.

Using Default Values

You can set the default values for the range date picker by passing the defaultValue prop to the RangePickerInput component in the form of an Array of two date strings.

Primitives

You can utilize the primitive components to customize the date picker.

ComponentDescription
DatePickerRootThe main container for the date-picker items.
DatePickerLabelThe label for the date-picker.
DatePickerControlThe control for the date-picker.
DatePickerInputThe input field and trigger for the date-picker.
DatePickerTriggerThe trigger for the date-picker.
DatePickerClearTriggerThe trigger to clear the date-picker.
DatePickerPositionerThe positioner for the date-picker.
DatePickerContentThe content of the date-picker calendar.
DatePickerYearSelectThe select input for the year in the date-picker.
DatePickerMonthSelectThe select input for the month in the date-picker.
DatePickerViewThe container (view) of the calendar.
DatePickerContextThe context provider for the date-picker calendar.
DatePickerViewControlThe triggers that update the calendar in the view.
DatePickerPrevTriggerThe trigger to navigate to the previous view.
DatePickerNextTriggerThe trigger to navigate to the next view.
DatePickerViewTriggerThe trigger to navigate to a specific view.
DatePickerRangeTextThe text that displays the range of dates selected.
DatePickerTableThe table that contains the calendar.
DatePickerTableRowThe row of the calendar table.
DatePickerTableHeadThe header of the calendar table.
DatePickerTableHeaderThe header cell of the calendar table.
DatePickerTableBodyThe body of the calendar table.
DatePickerTableCellThe cell of the calendar table.
DatePickerTableTriggerThe trigger of the cell in the calendar table.

API

Props

DatePicker

The DatePicker component accepts all the props of the DatePickerRoot primitive

DatePickerLabel

The DatePickerLabel component accepts all the props of the DatePickerLabel primitive

DatePickerInput

The DatePickerInput component accepts all the props of the DatePickerInputEl primitive

DatePickerCalendar

The DatePickerCalendar component is an abstraction of the primitives and accepts the following props:

NameDefaultDescription
withModalfalseWhether the Picker is used within a Dialog.

Parts

The DatePickerParts API is an Object containing the full family of components.

NameDescription
RootThe DatePickerRoot component and main container for the date-picker items.
LabelThe DatePickerLabel component and label for the date-picker.
ControlThe DatePickerControl component and control for the date-picker.
InputThe DatePickerInput component and input field and trigger for the date-picker.
TriggerThe DatePickerRoot component and trigger for the date-picker.
ClearTriggerThe DatePickerClearTrigger component and trigger to clear the date-picker.
PositionerThe DatePickerPositioner component and positioner for the date-picker.
ContentThe DatePickerContent component and content of the date-picker calendar.
YearSelectThe DatePickerYearSelect component and select input for the year in the date-picker.
MonthSelectThe DatePickerMonthSelect component and select input for the month in the date-picker.
ViewThe DatePickerView component and container (view) of the calendar.
ContextThe DatePickerContext component and context provider for the date-picker calendar.
ViewControlThe DatePickerViewControl component and triggers that update the calendar in the view.
PrevTriggerThe DatePickerPrevTrigger component and trigger to navigate to the previous view.
NextTriggerThe DatePickerNextTrigger component and trigger to navigate to the next view.
ViewTriggerThe DatePickerViewTrigger component and trigger to navigate to a specific view.
RangeTextThe DatePickerRangeText component and text that displays the range of dates selected.
TableThe DatePickerTable component and table that contains the calendar.
TableRowThe DatePickerTableRow component and row of the calendar table.
TableHeadThe DatePickerTableHead component and header of the calendar table.
TableHeaderThe DatePickerTableHeader component and header cell of the calendar table.
TableBodyThe DatePickerTableBody component and body of the calendar table.
TableCellThe DatePickerTableCell component and cell of the calendar table.
TableTriggerThe DatePickerTableTrigger component and trigger of the cell in the calendar table.