Date Picker API
View componentThe full prop reference for the Date Picker component. A calendar inside a popover for picking a date.
Import
import { DatePicker } from '@structyl/styled';Props
DatePicker (main)
A styled date picker component with label, helper text, and integrated trigger/content. The default export, suitable for most use cases.
| Prop | Type | Default |
|---|---|---|
| value# | Date | nullControlled selected date value | — |
| defaultValue# | Date | nullDefault date when uncontrolled | — |
| onChange# | (date: Date | null, context: PickerChangeContext<DateValidationError>) => voidCallback when date value changes | — |
| onValueChange# | (date: Date | undefined) => voidSimplified callback when date value changes | — |
| onAccept# | (date: Date | null, context: PickerChangeContext<DateValidationError>) => voidCallback when a date is accepted/committed | — |
| onError# | (error: DateValidationError | null, value: Date | null) => voidCallback when validation error occurs | — |
| open# | booleanControlled popover open state | — |
| defaultOpen# | booleanDefault open state when uncontrolled | — |
| onOpenChange# | (open: boolean) => voidCallback when open state changes | — |
| onOpen# | () => voidCallback when popover opens | — |
| onClose# | () => voidCallback when popover closes | — |
| closeOnSelect# | booleanClose popover immediately after selecting a date | true |
| disabled# | booleanDisable all date picker interactions | — |
| readOnly# | booleanPrevent value changes (read-only mode) | — |
| minDate# | DateMinimum selectable date | — |
| maxDate# | DateMaximum selectable date | — |
| disablePast# | booleanDisable all dates before today | — |
| disableFuture# | booleanDisable all dates after today | — |
| disabledDays# | (date: Date) => booleanPredicate function to disable specific dates | — |
| shouldDisableDate# | (date: Date) => booleanPredicate function to disable specific dates (alias for disabledDays) | — |
| shouldDisableMonth# | (date: Date) => booleanPredicate function to disable specific months | — |
| shouldDisableYear# | (date: Date) => booleanPredicate function to disable specific years | — |
| weekStartsOn# | numberStarting day of the week (0=Sunday, 1=Monday, etc.) | 0 |
| locale# | stringLocale for date formatting and localization | — |
| autoFocus# | booleanAuto-focus the trigger on mount | — |
| dayOfWeekFormatter# | (date: Date) => stringCustom formatter for day-of-week headers | — |
| disableHighlightToday# | booleanDisable visual highlight of today's date | — |
| disableOpenPicker# | booleanDisable opening the date picker (trigger becomes non-interactive) | — |
| displayWeekNumber# | booleanShow week numbers in the calendar | — |
| fixedWeekNumber# | numberFixed number of weeks to display per month | — |
| format# | Intl.DateTimeFormatOptions | stringDate format for display (Intl options or pattern like 'MM/DD/YYYY') | { dateStyle: 'medium' } |
| formatDensity# | 'dense' | 'spacious'Spacing density for formatted date output | 'dense' |
| loading# | booleanShow loading state in popover | — |
| renderLoading# | () => React.ReactNodeCustom loading indicator render function | — |
| showDaysOutsideCurrentMonth# | booleanDisplay days from adjacent months in calendar grid | — |
| label# | React.ReactNodeLabel text displayed above the trigger | — |
| helperText# | React.ReactNodeHelper text displayed below the trigger | — |
| placeholder# | React.ReactNodePlaceholder text when no date is selected | 'MM/DD/YYYY' |
| id# | stringHTML id attribute for the trigger element | — |
| name# | stringHTML name attribute for the trigger element | — |
| required# | booleanMark the label with a required indicator | — |
| error# | booleanMark helper text and trigger as errored | — |
| showOutsideDays# | booleanAlias for showDaysOutsideCurrentMonth | — |
| className# | stringCSS class for the root wrapper | — |
| triggerClassName# | stringCSS class for the trigger button | — |
| contentClassName# | stringCSS class for the popover content | — |
| calendarClassName# | stringCSS class for the calendar component | — |
| rootProps# | React.ComponentPropsWithoutRef<'div'>Native HTML props forwarded to root wrapper div (onClick, style, role, data-*, aria-*) | — |
DatePicker.Root
The root provider component for date picker context and popover state management. Used for building custom layouts.
| Prop | Type | Default |
|---|---|---|
| children# | React.ReactNodeChild components (Trigger, Content, etc.) | — |
| value# | Date | nullControlled selected date | — |
| defaultValue# | Date | nullDefault date when uncontrolled | — |
| onChange# | (date: Date | null, context: PickerChangeContext<DateValidationError>) => voidCalled when date changes | — |
| onValueChange# | (date: Date | undefined) => voidSimplified date change callback | — |
| onAccept# | (date: Date | null, context: PickerChangeContext<DateValidationError>) => voidCalled when date is accepted | — |
| onError# | (error: DateValidationError | null, value: Date | null) => voidCalled on validation error | — |
| open# | booleanControlled popover open state | — |
| defaultOpen# | booleanDefault popover open state | — |
| onOpenChange# | (open: boolean) => voidCalled when popover open state changes | — |
| onOpen# | () => voidCalled when popover opens | — |
| onClose# | () => voidCalled when popover closes | — |
| closeOnSelect# | booleanAuto-close popover after date selection | true |
| disabled# | booleanDisable interactions | — |
| readOnly# | booleanRead-only mode | — |
| minDate# | DateMinimum selectable date | — |
| maxDate# | DateMaximum selectable date | — |
| disablePast# | booleanDisable past dates | — |
| disableFuture# | booleanDisable future dates | — |
| disabledDays# | (date: Date) => booleanPredicate to disable specific dates | — |
| shouldDisableDate# | (date: Date) => booleanPredicate to disable specific dates | — |
| shouldDisableMonth# | (date: Date) => booleanPredicate to disable specific months | — |
| shouldDisableYear# | (date: Date) => booleanPredicate to disable specific years | — |
| weekStartsOn# | numberFirst day of week (0=Sunday, 1=Monday, etc.) | 0 |
| locale# | stringLocale for formatting | — |
| autoFocus# | booleanAuto-focus trigger | — |
| dayOfWeekFormatter# | (date: Date) => stringCustom day-of-week formatter | — |
| desktopModeMediaQuery# | stringMedia query for desktop mode detection | — |
| disableHighlightToday# | booleanDon't highlight today | — |
| disableOpenPicker# | booleanDisable opening picker | — |
| displayWeekNumber# | booleanShow week numbers | — |
| fixedWeekNumber# | numberFixed weeks per month | — |
| format# | Intl.DateTimeFormatOptions | stringDate format specification | — |
| formatDensity# | 'dense' | 'spacious'Format spacing | — |
| inputRef# | React.Ref<HTMLInputElement>Ref to underlying input element | — |
| keepOpenDuringFieldFocus# | booleanKeep popover open when field is focused | — |
| label# | React.ReactNodeLabel node | — |
| loading# | booleanShow loading state | — |
| localeText# | PickerLocaleTextLocalized text overrides (Record<string, React.ReactNode>) | — |
| monthsPerRow# | 3 | 4Months to display per row in month view | — |
| name# | stringForm input name | — |
| onMonthChange# | (month: Date) => voidCalled when displayed month changes | — |
| onSelectedSectionsChange# | (newValue: PickerSelectedSections) => voidCalled when selected field section changes | — |
| onViewChange# | (view: DatePickerView) => voidCalled when view changes (day/month/year) | — |
| onYearChange# | (year: Date) => voidCalled when displayed year changes | — |
| openTo# | 'day' | 'month' | 'year'Initial view when opened | 'day' |
| orientation# | 'landscape' | 'portrait'Picker layout orientation | — |
| reduceAnimations# | booleanDisable animations | — |
| referenceDate# | DateReference date for calculations | — |
| renderLoading# | () => React.ReactNodeCustom loading render function | — |
| selectedSections# | PickerSelectedSectionsControlled selected field section | — |
| defaultSelectedSections# | PickerSelectedSectionsDefault selected field section | — |
| showDaysOutsideCurrentMonth# | booleanShow adjacent month days | — |
| slotProps# | PickerSlotPropsSlot component props (Record<string, unknown>) | — |
| slots# | PickerSlotsSlot component overrides (Record<string, React.ElementType>) | — |
| sx# | PickerSxSystem prop styles | — |
| timezone# | stringTimezone for date operations | — |
| view# | 'day' | 'month' | 'year'Controlled current view | — |
| defaultView# | 'day' | 'month' | 'year'Default initial view | — |
| viewRenderers# | Partial<Record<DatePickerView, DatePickerViewRenderer | null>>Custom renderers per view (day/month/year) | — |
| views# | ('day' | 'month' | 'year')[]Array of enabled views | — |
| yearsOrder# | 'asc' | 'desc'Year list sort order | — |
| yearsPerRow# | 3 | 4Years to display per row in year view | — |
DatePicker.Trigger
The button that opens the date picker popover. Inherits from Popover.Trigger.
| Prop | Type | Default |
|---|---|---|
| asChild# | booleanRender as child element instead of button | — |
| className# | stringCSS class | — |
| disabled# | booleanDisable the trigger button | — |
| children# | React.ReactNodeTrigger content | — |
| onClick# | (event: React.MouseEvent<HTMLButtonElement>) => voidClick handler | — |
| Standard HTML button attributes# | variousaria-*, data-*, role, tabIndex, style, etc. | — |
DatePicker.Content
The popover content wrapper containing the calendar. Inherits from Popover.Content with additional date picker props.
| Prop | Type | Default |
|---|---|---|
| align# | 'start' | 'center' | 'end'Alignment relative to trigger | 'center' |
| side# | 'top' | 'right' | 'bottom' | 'left'Position relative to trigger | — |
| sideOffset# | numberDistance from trigger | 6 |
| alignOffset# | numberAlignment offset | — |
| arrowPadding# | numberArrow padding from edges | — |
| avoidCollisions# | booleanAuto-adjust position to avoid collisions | — |
| collisionBoundary# | Element | Element[] | nullCollision detection boundary | — |
| collisionPadding# | numberPadding for collision detection | — |
| strategy# | 'fixed' | 'absolute'Positioning strategy | — |
| sticky# | 'partial' | 'always'Sticky behavior | — |
| hideWhenDetached# | booleanHide when trigger is off-screen | — |
| updatePositionStrategy# | 'always' | 'optimized'Position update frequency | — |
| asChild# | booleanRender as child element | — |
| forceMount# | booleanForce mount in DOM (even when closed) | — |
| onOpenAutoFocus# | (event: Event) => voidFocus trap on open | — |
| onCloseAutoFocus# | (event: Event) => voidFocus return on close | — |
| onEscapeKeyDown# | (event: KeyboardEvent) => voidEscape key handler | — |
| onPointerDownOutside# | (event: PointerDownOutsideEvent) => voidPointer down outside handler | — |
| onFocusOutside# | (event: FocusOutsideEvent) => voidFocus outside handler | — |
| onInteractOutside# | (event: PointerDownOutsideEvent | FocusOutsideEvent) => voidGeneric outside interaction handler | — |
| className# | stringCSS class | — |
| calendarClassName# | stringCSS class for inner calendar | — |
| loading# | booleanShow loading indicator | — |
| showOutsideDays# | booleanDisplay adjacent month days | — |
| showDaysOutsideCurrentMonth# | booleanDisplay adjacent month days (alias) | — |
| Standard HTML div attributes# | variousstyle, data-*, role, aria-*, etc. | — |
DatePicker.Calendar
The calendar grid component. Inherits from Calendar.Root with date picker context integration.
| Prop | Type | Default |
|---|---|---|
| minDate# | DateMinimum selectable date | — |
| maxDate# | DateMaximum selectable date | — |
| disablePast# | booleanDisable past dates | — |
| disableFuture# | booleanDisable future dates | — |
| disabled# | booleanDisable calendar | — |
| disabledDays# | (date: Date) => booleanDisable predicate for dates | — |
| shouldDisableDate# | (date: Date) => booleanDisable predicate for dates | — |
| shouldDisableMonth# | (date: Date) => booleanDisable predicate for months | — |
| shouldDisableYear# | (date: Date) => booleanDisable predicate for years | — |
| weekStartsOn# | numberFirst day of week | 0 |
| locale# | stringLocale for formatting | — |
| disableHighlightToday# | booleanDon't highlight today | — |
| displayWeekNumber# | booleanShow week numbers | — |
| fixedWeekNumber# | numberFixed weeks per month | — |
| showDaysOutsideCurrentMonth# | booleanShow adjacent month days | — |
| dayOfWeekFormatter# | (date: Date) => stringCustom day-of-week formatter | — |
| onMonthChange# | (month: Date) => voidMonth change callback | — |
| onYearChange# | (year: Date) => voidYear change callback | — |
| className# | stringCSS class | — |
| showOutsideDays# | booleanShow adjacent month days (alias) | — |
| Standard HTML div attributes# | variousstyle, data-*, role, aria-*, etc. | — |
DatePicker.Value
A text component that displays the formatted selected date or a placeholder.
| Prop | Type | Default |
|---|---|---|
| format# | Intl.DateTimeFormatOptions | stringDate format (Intl options or pattern string) | { dateStyle: 'medium' } |
| formatDensity# | 'dense' | 'spacious'Spacing for formatted output | 'dense' |
| locale# | stringLocale for formatting | — |
| placeholder# | React.ReactNodeText when no date is selected | 'Pick a date' |
DatePicker.Loading
A component that displays a loading indicator or custom loading content.
| Prop | Type | Default |
|---|---|---|
| No props# | noneUses context renderLoading or localeText.loading from DatePicker.Root | — |
Source code
If you didn't find what you need here, read the component implementation .