Your next page is taking shape...

Opening Your Next Page…

Loading the guide and preparing its examples for you to explore. The page will appear here automatically when it’s ready, so you can keep this view open without refreshing.

Made for Preact. Built to be yours.

Forms & Input

Calendar

A calendar component that allows users to select a date or a range of dates — aligned with the structure and examples on ui.shadcn.com (Radix docs). Make the expected input clear before someone interacts, and keep the current value, help text and validation feedback connected. Import it from @/components/kamod-ui/calendar.

Source · Design reference · API reference · Theming · Styles


Interactive Live Preview
Try it. Make it yours.
Setting the scene...

Interactive preview

Live Preact example Local preview theme · Responsive styles follow the preview widthFull width

Installation

Add @kamod-ch/ui to your app and import Calendar. This implementation mirrors the shadcn/ui Calendar API Surface (modes, captions, disabled, modifiers, week numbers, RTL) without bundling react-day-picker; see [React DayPicker](https://react-day-picker.js.org/) for the upstream reference behaviour.

Install PackagesTerminal
pnpm add @kamod-ch/ui

Copy an example with @kamod-ch/ui or the matching @kamod-ch/ui/… subpath. The code block switches between those two installs. Connect The Global Theme CSS and Tailwind Source Detection before your first render.

Interactive Live Preview
Try it. Make it yours.
Setting the scene...

Interactive preview

Live Preact example Local preview theme · Responsive styles follow the preview widthFull width

Usage

Import Calendar from @/components/kamod-ui/calendar, then control selected/onSelect in mode="single" or pass a DateRange in mode="range". The shadcn Calendar wraps React DayPicker; Kamod provides a lightweight grid with a parallel prop surface for demos and composition. Build a date picker with Popover and Button (see /docs/date-picker/installation in this app). If the highlighted day shifts vs your timezone, pass timeZone from Intl.DateTimeFormat().resolvedOptions().timeZone on the client (useEffect), as documented on ui.shadcn.com. For a tighter layout (e.g. narrow popovers), pass size="sm".

Import SetupTypeScript
import { Calendar } from "@kamod-ch/ui";

Choose a complete composition from the examples below; required child components and props vary by pattern.

Component Examples & Variants

Explore Calendar in Different Contexts, from the starting pattern to the compositions below. Begin with Demo, then compare the examples that match your content, state and layout. These are working patterns to adapt, not a list of interchangeable variant values: check the API Reference before using a prop or combining behaviors. Look at the surrounding labels, supporting text and spacing as well as the component itself.

Read the Result and Its Implementation Together. Use each showcase’s Code view to inspect imports and composition, or its Prompt view to prepare a setup or adaptation brief. Try the narrow preview and local theme controls before connecting real data, and use Reset to return an example to its initial state. Keep layout changes in class utilities where appropriate; follow the Component Styles Guide for hierarchy and the Theming Guide for shared surfaces and colors. The Accessibility Notes explain what to preserve when making those changes.

Demo

Make Date Selection Easy to Orient. Use captionLayout="dropdown" to let people jump between months and years from the calendar header. The day grid remains the date-selection surface, while the caption provides a faster way to reach distant dates.

Keep the surrounding field label clear, decide which dates the application accepts, and compare Date Picker when the calendar belongs inside an input workflow.

src/components/CalendarExample.tsx18 lines
"use client"

import { Calendar } from "@kamod-ch/ui"
import { useState } from "preact/hooks"

export function CalendarDemo() {
  const [date, setDate] = useState<Date | undefined>(new Date())

  return (
    <Calendar
      mode="single"
      selected={date}
      onSelect={(d) => setDate(d as Date)}
      class="rounded-lg border"
      captionLayout="dropdown"
    />
  )
}

Selected Date (with TimeZone)

Choose Which Calendar Day the Value Represents. Pass timeZone when the calendar's displayed dates need a specific zone. If it comes from the browser, detect it after mounting so the server and initial client render begin from a consistent value.

Establish the zone before formatting a selected date, keep server and client rendering consistent, and test dates near midnight rather than assuming a UTC conversion preserves the intended day.

Interactive Live Preview
Try it. Make it yours.
Setting the scene...

Interactive preview

Live Preact example Local preview theme · Responsive styles follow the preview widthFull width

Basic

Start with a Focused Date-Selection Surface. Start with one calendar and a simple class="rounded-lg border" frame. This isolates day selection from surrounding popovers or form fields, making it easier to understand before adding a larger date-entry workflow.

Add application-specific bounds and unavailable dates deliberately, and keep the selected date visible in text when it is part of a larger form.

Interactive Live Preview
Try it. Make it yours.
Setting the scene...

Interactive preview

Live Preact example Local preview theme · Responsive styles follow the preview widthFull width

Range Calendar

Make Both Ends of the Range Understandable. Use mode="range" with two visible months to compare the start and end of a period. An optional disabled predicate can exclude dates that should not be available for the user's selection.

Test ranges that cross months and unavailable days; visual range styling does not replace your application's booking or validation rules.

Interactive Live Preview
Try it. Make it yours.
Setting the scene...

Interactive preview

Live Preact example Local preview theme · Responsive styles follow the preview widthFull width

Month and Year Selector

Support dates far from today. Set captionLayout="dropdown" for direct month and year selection alongside the previous/next controls. Pass locale for localized month labels so the calendar's navigation uses the same language as its surrounding field.

Pick sensible year bounds for the task and verify localized month labels; users should not need to step through dozens of months to reach a valid choice.

Interactive Live Preview
Try it. Make it yours.
Setting the scene...

Interactive preview

Live Preact example Local preview theme · Responsive styles follow the preview widthFull width

Presets

Offer Shortcuts without Removing Precise Selection. Control month through onMonthChange when shortcut buttons should move the visible calendar. fixedWeeks keeps a six-row grid, reducing movement when navigating between months with different numbers of displayed weeks.

Keep the displayed month and selected value coordinated, and label each shortcut according to what it actually changes rather than implying a range it does not select.

Interactive Live Preview
Try it. Make it yours.
Setting the scene...

Interactive preview

Live Preact example Local preview theme · Responsive styles follow the preview widthFull width

Date and Time Picker

Treat Date and Time as One Application Value. Combine the calendar with time fields in the card footer when a task needs both a day and a time. These remain separate inputs; your application decides how their values form the final date-time payload.

Explain the relevant time zone, handle incomplete values, and verify that editing the time does not unexpectedly reset the selected date.

Interactive Live Preview
Try it. Make it yours.
Setting the scene...

Interactive preview

Live Preact example Local preview theme · Responsive styles follow the preview widthFull width

Booked Dates

Distinguish Unavailable Days from Selected Ones. Use disabled to prevent choosing booked dates and modifiers with modifiersClassNames to distinguish them visually. Styling explains the availability rule, while the disabled predicate enforces the calendar's selection behavior.

Include explanatory text for the booking rules, and test a mix of adjacent available and booked dates so the calendar does not rely on color alone.

Interactive Live Preview
Try it. Make it yours.
Setting the scene...

Interactive preview

Live Preact example Local preview theme · Responsive styles follow the preview widthFull width

Custom Cell Size

Leave Room for Useful Day Details. Adjust --cell-size for the available width and use dayAddon for secondary information such as a daily price. The source also compares fixed sizes so you can choose a density appropriate to the surrounding layout.

Keep the primary day number readable, scale the cell size for narrow screens, and avoid turning secondary information into a second competing selection target.

Interactive Live Preview
Try it. Make it yours.
Setting the scene...

Interactive preview

Live Preact example Local preview theme · Responsive styles follow the preview widthFull width

Week Numbers

Add Context for Week-Based Planning. Enable showWeekNumber to add ISO week indices beside the day grid. This is useful when schedules are organized by week, giving readers a reference without replacing the individual date labels.

Confirm that the convention matches your users' expectations and keep the numbers visually secondary to selectable days; explain the convention if the surrounding product uses another calendar system.

Interactive Live Preview
Try it. Make it yours.
Setting the scene...

Interactive preview

Live Preact example Local preview theme · Responsive styles follow the preview widthFull width
API reference

Props and Data

Configure Calendar using the contracts below. Read the documented options alongside the Source Definitions to understand which values your application supplies and which details the component owns. Start with a prop or helper, then follow its type link to inspect the declaration without leaving the page.

Props, slots and variants for this component.

API reference
Your API, from source

Type cards are extracted from this checkout’s TypeScript source at build time. Props inherited through HTMLAttributes, Omit or variant helpers remain references in those declarations; their fields are not flattened here. Match the reference to your installed version, and check a package’s exports before writing an import type. A type exported by a source file is not necessarily re-exported by @kamod-ch/ui.

Component Props

Read each option with its owning component. The
marker identifies required fields verified in that declaration. A ? means a field can be omitted; it does not promise a fallback value. Existing documented defaults remain alongside the descriptions. For callbacks, check the argument and return types before connecting your own state or services.
@kamod-ch/ui/calendar54.2 KB min · 11.9 KB gzipSignals: none

Calendar

CalendarProps

Calendar documented props
Prop / typeDescription
captionLayout
"buttons" | "dropdown"CalendarProps

Configure captionLayout for Calendar. Compare its accepted type with the Usage Guidance before supplying a value.

Default
"buttons"
captionTitleClass
stringCalendarProps

Extra classes for the visible month/year caption text (single-month buttons layout and dual-month titles).

Default
—
class
string | SignalLike<string | undefined>CalendarProps

Configure class for Calendar. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
dayAddon
((date: Date, outside: boolean) => ComponentChildren | undefined)CalendarProps

Extra label under the day number (e.g. prices). Omit or return `undefined` for outside days if desired.

Default
—
defaultMonth
DateCalendarProps

Configure defaultMonth for Calendar. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
dir
"rtl" | "ltr" | (SignalLike<"auto" | "rtl" | "ltr" | undefined> & "rtl") | (SignalLike<"auto" | "rtl" | "ltr" | undefined> & "ltr")CalendarProps

Configure dir for Calendar. Compare its accepted type with the Usage Guidance before supplying a value.

Default
"ltr"
disabled
CalendarDisabledPropCalendarProps

Configure disabled for Calendar. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
fixedWeeks
booleanCalendarProps

Pad to six week rows.

Default
false
locale
stringCalendarProps

BCP 47 locale for captions and weekday labels.

Default
—
mode
CalendarModeCalendarProps

Configure mode for Calendar. Compare its accepted type with the Usage Guidance before supplying a value.

Default
"single"
modifiers
Record<string, Date[]>CalendarProps

Named date sets for styling via `modifiersClassNames`.

Default
—
modifiersClassNames
Record<string, string>CalendarProps

Tailwind / arbitrary classes keyed like `modifiers` (e.g. booked).

Default
—
month
DateCalendarProps

Configure month for Calendar. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
numberOfMonths
1 | 2CalendarProps

Configure numberOfMonths for Calendar. Compare its accepted type with the Usage Guidance before supplying a value.

Default
1
onMonthChange
((next: Date) => void)CalendarProps

Configure onMonthChange for Calendar. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
onSelect
((value: Date | DateRange | undefined) => void)CalendarProps

Configure onSelect for Calendar. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
onValueChange
((next: Date) => void)CalendarProps

Configure onValueChange for Calendar. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
selected
Date | DateRangeCalendarProps

Configure selected for Calendar. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
showOutsideDays
booleanCalendarProps

Show days from adjacent months.

Default
true
showWeekdayLeadBorder
booleanCalendarProps

Decorative left border on the first weekday column (e.g. Su).

Default
false
showWeekNumber
booleanCalendarProps

Extra week-index column (ISO week of row start).

Default
false
size
CalendarSizeCalendarProps

Visual density; `sm` fits popovers and tight layouts.

Default
"default"
timeZone
stringCalendarProps

Passed to `Intl` where supported; selection still uses local `Date` (use noon-normalized dates to avoid TZ drift).

Default
—
value
DateCalendarProps

Configure value for Calendar. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
weekdayLabels
string[]CalendarProps

If set (length 7, Sunday-first), overrides locale-derived weekday headers.

Default
—

CalendarDateTimePanel

CalendarDateTimePanelProps

CalendarDateTimePanel documented props
Prop / typeDescription
captionLayout
"buttons" | "dropdown"CalendarDateTimePanelProps

Configure captionLayout for CalendarDateTimePanel. Compare its accepted type with the Usage Guidance before supplying a value.

Default
"buttons"
class
string | SignalLike<string | undefined>CalendarDateTimePanelProps

Configure class for CalendarDateTimePanel. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
compactWeekdays
booleanCalendarDateTimePanelProps

Use two-letter weekday headers (Su–Sa).

Default
true
defaultEndTime
stringCalendarDateTimePanelProps

Configure defaultEndTime for CalendarDateTimePanel. Compare its accepted type with the Usage Guidance before supplying a value.

Default
"12:30:00"
defaultMonth
DateCalendarDateTimePanelProps

Configure defaultMonth for CalendarDateTimePanel. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
defaultSelected
DateCalendarDateTimePanelProps

Initial day when uncontrolled.

Default
—
defaultStartTime
stringCalendarDateTimePanelProps

Configure defaultStartTime for CalendarDateTimePanel. Compare its accepted type with the Usage Guidance before supplying a value.

Default
"10:30:00"
dir
(("auto" | "rtl" | "ltr" | SignalLike<"auto" | "rtl" | "ltr" | undefined>) & ("rtl" | "ltr" | (SignalLike<"auto" | "rtl" | "ltr" | undefined> & "rtl") | (SignalLike<"auto" | "rtl" | "ltr" | undefined> & "ltr")))CalendarDateTimePanelProps

Configure dir for CalendarDateTimePanel. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
disabled
CalendarDisabledPropCalendarDateTimePanelProps

Configure disabled for CalendarDateTimePanel. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
endTime
stringCalendarDateTimePanelProps

Configure endTime for CalendarDateTimePanel. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
endTimeLabel
stringCalendarDateTimePanelProps

Configure endTimeLabel for CalendarDateTimePanel. Compare its accepted type with the Usage Guidance before supplying a value.

Default
"End Time"
locale
stringCalendarDateTimePanelProps

BCP 47 locale for captions and weekday labels.

Default
"en-US"
month
DateCalendarDateTimePanelProps

Configure month for CalendarDateTimePanel. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
onEndTimeChange
((value: string) => void)CalendarDateTimePanelProps

Configure onEndTimeChange for CalendarDateTimePanel. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
onMonthChange
((next: Date) => void)CalendarDateTimePanelProps

Configure onMonthChange for CalendarDateTimePanel. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
onSelect
((date: Date) => void)CalendarDateTimePanelProps

Configure onSelect for CalendarDateTimePanel. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
onStartTimeChange
((value: string) => void)CalendarDateTimePanelProps

Configure onStartTimeChange for CalendarDateTimePanel. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
selected
DateCalendarDateTimePanelProps

Selected calendar day (controlled).

Default
—
showOutsideDays
booleanCalendarDateTimePanelProps

Show days from adjacent months.

Default
true
showWeekdayLeadBorder
booleanCalendarDateTimePanelProps

Decorative line left of the first weekday; off by default.

Default
false
size
CalendarSizeCalendarDateTimePanelProps

Visual density; `sm` fits popovers and tight layouts.

Default
"sm"
startTime
stringCalendarDateTimePanelProps

`HH:mm` or `HH:mm:ss` for native `input[type=time]`.

Default
—
startTimeLabel
stringCalendarDateTimePanelProps

Configure startTimeLabel for CalendarDateTimePanel. Compare its accepted type with the Usage Guidance before supplying a value.

Default
"Start Time"

Data Type Reference

Expand a card to inspect and copy the exact declaration. The code header identifies its repository file; follow imported or inherited types in the Implementation Source when you need the complete dependency chain. Required-field summaries cover fields declared directly in that type. Source-only helpers and inferred schema outputs describe the local implementation, not additional props you can pass to every component.

DateRange

2 declared fields
DateRange
Exported Source Declaration from Calendar.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of DateRange before adapting it.

CalendarMode

Declaration
CalendarMode
Exported Source Declaration from Calendar.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of CalendarMode before adapting it.

CalendarSize

Declaration
CalendarSize
`sm`: denser padding, smaller day cells, lighter caption controls (dropdown + nav). Inspect the Complete Definition of CalendarSize before adapting it.
CalendarDisabledProp
Exported Source Declaration from Calendar.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of CalendarDisabledProp before adapting it.

Calendar Props

24 declared fields
CalendarProps
Exported Source Declaration from Calendar.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of CalendarProps before adapting it.

MonthCaption Props

10 declared fields
MonthCaptionProps
Local Source Declaration from Calendar.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of MonthCaptionProps before adapting it.
Required fields
displayMonth, captionLayout, dir, size, onPrev, onNext, onPickMonthYear

DualMonthCaption Props

9 declared fields
DualMonthCaptionProps
Local Source Declaration from Calendar.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of DualMonthCaptionProps before adapting it.
Required fields
firstMonth, secondMonth, dir, size, onPrev, onNext

MonthGrid Props

17 declared fields
MonthGridProps
Local Source Declaration from Calendar.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of MonthGridProps before adapting it.
Required fields
year, month, mode, showOutsideDays, fixedWeeks, showWeekNumber, isDisabled, modifierClassesFor, hasDayAddon, size, onDayClick

CalendarDateTimePanel Props

13 declared fields
CalendarDateTimePanelProps
Exported Source Declaration from CalendarDateTimePanel.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of CalendarDateTimePanelProps before adapting it.

Accessibility

Build the Complete Interaction, Including the Parts Outside Calendar. The notes below distinguish the current implementation from the labels, content and behavior your application supplies. Start with the Live Preview, check the Props and Data Reference, and test the finished composition with real content rather than assuming that an unchanged visual example covers every use case.

Built-in Behavior and Defaults

Calendar provides day buttons and named previous/next-month controls; dropdown captions label month and year selectors. Those visible controls are useful building blocks, but a button calendar should not be assumed to implement every ARIA date-grid keyboard convention.

Labels and Relationships

Explain what date is being selected and the allowed date range. Make the displayed month, selected day and unavailable dates understandable beyond their color. When a day number is ambiguous, verify the rendered button name supplies enough date context.

Keyboard and Focus

Check how Tab reaches days and month controls in the current variant before documenting shortcuts. Keep month changes and selection predictable. A disabled day needs an explanation when the reason cannot be understood from the surrounding booking or scheduling instructions.

States and Integration Details

Do not assume locale formatting also changes every accessible label. Review weekday names, date order and navigation labels after localization. Keep a text-entry alternative for workflows where traversing a large date range is burdensome.

Verify the Complete Interaction

Check Behavior as Well as Markup. Work through these scenarios in the application where the component will be used. Automated checks can help find structural problems; also review the reading experience with a screen reader, keyboard focus and the actual feedback from your application.

  1. Choose a date using only the keyboard, including crossing month and year boundaries.
  2. Read selected, today and unavailable states with assistive technology rather than relying on visual styling.
  3. Test localized labels, long month names, text zoom and touch use with the exact calendar variant.

Recheck the result after changing Theme Tokens, translations or class overrides. Include text enlargement, narrow layouts and reduced-motion settings where animation is present. Inspect the Component Source when a behavior differs from your expectation; a role or state attribute does not implement keyboard interaction by itself.

For background, read the WAI-ARIA Authoring Guidance and Keyboard Interface Guidance. These explain the patterns; verify browser and assistive-technology behavior for the implementation and audience you actually support.

Take the Next Useful Step

You have the pieces. Put them into one real interaction, keep its state in one place, and check the result with the content your application will actually show.

Connect the Foundation

Return to Choose and Compose Components to connect this reference to a working screen. Keep global CSS in one entrypoint and import only the components that screen needs.

Build the Surrounding Screen

Find a neighboring interaction in the Component Library, or start with a complete Block. Replace sample content and destinations before refining the layout; a local class change can stay with the composition.

Make the Result Hold Up

Use shared theme roles for changes that belong everywhere. Then review the whole journey: keyboard focus, long labels, narrow screens and a clear way to recover when something fails.

Keep a link to the source and note your intentional changes. Your next edit should begin with a clear decision, not another search.