Date Picker

Date picker with an interactive calendar, time picker, year and month dropdowns, min/max limits, and date-of-birth presets.

import { DatePicker } from "@plexui/ui/components/DatePicker";

Examples

Overview

Limits

Date of birth

Time picker

Two fields

Date input

DateTime input

Without Icon

Disabled

API

Use aria-labelledby with the ID of a visible field label. The trigger includes that label and its current date or placeholder in its accessible name. aria-label, aria-describedby and aria-invalid also reach the trigger.

In the calendar, the arrow keys move focus by a day or a week, Home and End move it to the Sunday or Saturday of the week, and Page Up and Page Down move it by a month (January 31 goes to the last day of February). A day in another month turns the calendar to that month first. Focus stays put when the day it would move to is outside min and max. Enter and Space select the focused day.

PropTypeDefaultDescription
valueDateTime | null—Required. Selected date (luxon)
onChange(date: DateTime | null) => void—Required. Called when the date changes
idstring—Id of the trigger, for forms and labels
minDateTime—Earliest selectable date (inclusive)
maxDateTime—Latest selectable date (inclusive). Must not be before min
captionLayout"buttons" | "dropdown""buttons"Calendar header mode. Use dropdown for date of birth
showTimebooleanfalseShow time input below calendar
yearRange[number, number]last 120 yearsMin/max years for dropdown caption
sizeControlSize"md"Trigger size (3xs to 3xl)
variant"outline" | "soft" | "ghost""outline"Trigger style
pillbooleantrueRounded trigger
blockbooleanfalseFull-width trigger
clearablebooleanfalseShow clear button
triggerShowIconbooleantrueShow calendar icon
triggerDateFormatstring"MM/dd/yy"Date format in trigger. Auto-includes time when showTime is enabled
triggerClassNamestring—Class applied to the trigger
dropdownIconType"dropdown" | "chevronDown" | "none""dropdown"Icon at the end of the trigger
placeholderstring"Select date..."Trigger placeholder
disabledbooleanfalseDisable picker
side"top" | "right" | "bottom" | "left""bottom"Preferred side of the calendar popover
sideOffsetnumber8Distance from the trigger in pixels
align"start" | "center" | "end""center"Alignment against the trigger
alignOffsetnumber0 (center), -5 (start, end)Offset from start/end alignment in pixels

Styling

Date Picker reads these component tokens. Override them at any scope to restyle it:

  • --input-border-color-invalid: border color invalid (default var(--color-border-danger-outline))
  • --input-outline-border-color: outline border color (default var(--color-border-primary-outline))
  • --input-outline-border-color-hover: outline border color hover (default light-dark(var(--alpha-25), var(--alpha-30)))
  • --input-placeholder-text-color: placeholder text color (default var(--color-text-tertiary))
  • --input-text-color: text color (default var(--color-text))
  • --select-control-font-weight: font weight (default var(--font-weight-normal))