Skip to content
Playground

Calendar

Date selection, single-date popovers, and date-range popovers powered by DayPicker.

Use Calendar for an inline date grid, DatePicker for one date in a popover, and DateRangePicker for a start and end date. All three use the same selection values and calendar behavior.

Powered by DayPicker for date-grid behavior, keyboard navigation, and accessible labels. Zenos owns the public selection API, popup composition, and styling.

pnpm dlx @zentara-co/zenos-cli add calendar

The command installs @daypicker/react and adds three consumer-owned files:

  • calendar.tsx — inline calendar with single, multiple, and range selection.
  • date-picker.tsx — shared picker state plus single-date Root, Trigger, and Content.
  • date-range-picker.tsx — range state built on the same trigger and content parts.

Import these files through the path configured by your project:

TSX
import { Calendar } from "./components/calendar";import { DatePicker } from "./components/date-picker";import { DateRangePicker } from "./components/date-range-picker";

Calendar supports single, multiple, and range modes. The mode narrows the value and callback types, so keep value, defaultValue, and onValueChange consistent with it.

Use single selection for appointments, deadlines, and effective dates. Omitting mode also selects this behavior.

Use multiple selection when dates are independent rather than a continuous interval, such as maintenance windows or attendance days.

Range selection returns { from, to }. During selection, from can exist before to; handle that partial state in labels and validation.

Use min and max for inclusive selection boundaries. Add disabled for business rules inside that interval. It accepts one DayPicker matcher or an array of matchers, including dates, ranges, day-of-week objects, and predicate functions.

Keep unavailable dates visibly disabled instead of rejecting them only after submission. Put server-side availability behind a feature hook and pass the resolved matchers into Calendar.

Use value with onValueChange when the selection participates in form state, validation, or another component. Use defaultValue when Calendar can own the selection after initialization.

Visible-month state is separate from selected-value state. Control navigation with month and onMonthChange, or provide only defaultMonth for an uncontrolled initial month.

TSX
const [month, setMonth] = useState(new Date(2026, 8));const [date, setDate] = useState<Date>(); <Calendar value={date} onValueChange={setDate} month={month} onMonthChange={setMonth} />;
PropTypeDefaultDescription
mode 'single' | 'multiple' | 'range' single Selection model and value type.
value Date | Date[] | DateRange | undefined — Controlled selection for the active mode.
defaultValue Date | Date[] | DateRange | undefined — Initial selection when Calendar owns its state.
onValueChange (value) => void — Runs when the selection changes; value follows mode.
disabled Matcher | Matcher[] — Dates unavailable for selection.
min / max Date — Earliest and latest selectable dates, inclusive.
month / defaultMonth Date — Controlled or initial visible month.
onMonthChange (month: Date) => void — Runs after visible-month navigation.
numberOfMonths number 1 Number of consecutive visible months.
locale / timeZone Locale / string — DayPicker localization and IANA time zone configuration.
className / native div props string / HTMLAttributes<HTMLDivElement> — Styles or labels the calendar wrapper.
DatePicker.Root
├── DatePicker.Trigger
└── DatePicker.Content
  └── Calendar mode="single"

DatePicker.Root provides single-date state to its nested Calendar. Selecting a date closes an open picker and returns focus to the trigger. Use open, defaultOpen, and onOpenChange when popup visibility needs an external owner.

The trigger uses the same visual variants as Zenos Input and integrates with Field.Root for id, disabled, required, invalid, description, and error semantics.

Use a controlled picker when another part of the screen needs the selected date. Calendar inherits the picker’s value and callback when no local value or defaultValue is supplied.

TSX
import { Field } from "@zentara-co/zenos-ui"; <Field.Root required>  <Field.Label>Deployment date</Field.Label>  <DatePicker.Root value={date} onValueChange={setDate}>    <DatePicker.Trigger>      {date ? date.toLocaleDateString() : "Choose deployment date"}    </DatePicker.Trigger>    <DatePicker.Content>      <Calendar min={new Date()} />    </DatePicker.Content>  </DatePicker.Root>  <Field.Description>Weekdays only.</Field.Description></Field.Root>;
DateRangePicker.Root
├── DateRangePicker.Trigger
└── DateRangePicker.Content
  └── Calendar mode="range"

The first selection keeps the popup open with a partial { from } value. Selecting an end date completes the range, closes the popup, and returns focus to the trigger.

Use two visible months when the expected ranges commonly cross a month boundary. For narrow layouts, keep one month or ensure the containing surface can accommodate the two-month grid.

Use one visible month when the picker appears in a narrow surface or most ranges stay within the same month. Users can still navigate between months to select a range that crosses a month boundary.

PropTypeDefaultDescription
value / defaultValue Date | DateRange | undefined — Controlled or initial picker selection; the exact type depends on the picker.
onValueChange (value) => void — Runs when the nested Calendar changes selection.
open / defaultOpen boolean — Controlled or initial popup visibility.
onOpenChange (open: boolean) => void — Runs when popup visibility changes.
modal boolean false Uses Base UI modal popover behavior when enabled.
PropTypeDefaultDescription
Trigger.variant InputVariant default Input-compatible trigger surface.
Trigger.render ReactElement | function — Composes the trigger with another button-like control.
Trigger.disabled boolean false Prevents the picker from opening; Field disabled state is inherited.
Content.side / align Base UI position values bottom / start Preferred popup placement relative to the trigger.
Content.sideOffset number 4 Distance in pixels between trigger and popup.
className string — Styling escape hatch on Trigger, Content, or Calendar.

Pass a DayPicker locale object and format the trigger label with the same locale. Use an IANA timeZone when the product’s calendar day must not depend on the viewer’s machine time zone.

TSX
import { enGB } from "@daypicker/react/locale"; <Calendar locale={enGB} timeZone="Europe/London" />;

Keep the stored domain value and display formatting deliberate. A JavaScript Date is an instant, while many product concepts—birthdays, billing days, booking dates—represent a calendar date without a time.

DayPicker supplies grid semantics, accessible day labels, and arrow-key navigation. Keep these behaviors intact:

  • Give standalone calendars an aria-label when the surrounding heading does not identify their purpose.
  • Use the trigger text to communicate the current value; do not rely on placeholder color alone.
  • Leave disabled dates focus-safe and visibly distinct.
  • Announce validation through Field.Error and aria-invalid rather than changing color only.
  • Preserve Escape-to-close and focus return for both picker variants.