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 preview
Preact example Local preview theme · Responsive styles follow the preview widthFull widthInstallation
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.
pnpm add @kamod-ch/uiCopy 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 preview
Preact example Local preview theme · Responsive styles follow the preview widthFull widthUsage
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 { 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.
"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 preview
Preact example Local preview theme · Responsive styles follow the preview widthFull widthBasic
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 preview
Preact example Local preview theme · Responsive styles follow the preview widthFull widthRange 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 preview
Preact example Local preview theme · Responsive styles follow the preview widthFull widthMonth 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 preview
Preact example Local preview theme · Responsive styles follow the preview widthFull widthPresets
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 preview
Preact example Local preview theme · Responsive styles follow the preview widthFull widthDate 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 preview
Preact example Local preview theme · Responsive styles follow the preview widthFull widthBooked 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 preview
Preact example Local preview theme · Responsive styles follow the preview widthFull widthCustom 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 preview
Preact example Local preview theme · Responsive styles follow the preview widthFull widthWeek 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 preview
Preact example Local preview theme · Responsive styles follow the preview widthFull widthProps 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.
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
? 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.Calendar
CalendarProps
| Prop / type | Description |
|---|---|
captionLayout | Configure
|
captionTitleClass | Extra classes for the visible month/year caption text (single-month buttons layout and dual-month titles).
|
class | Configure
|
dayAddon | Extra label under the day number (e.g. prices). Omit or return `undefined` for outside days if desired.
|
defaultMonth | Configure
|
dir | Configure
|
disabled | Configure
|
fixedWeeks | Pad to six week rows.
|
locale | BCP 47 locale for captions and weekday labels.
|
mode | Configure
|
modifiers | Named date sets for styling via `modifiersClassNames`.
|
modifiersClassNames | Tailwind / arbitrary classes keyed like `modifiers` (e.g. booked).
|
month | Configure
|
numberOfMonths | Configure
|
onMonthChange | Configure
|
onSelect | Configure
|
onValueChange | Configure
|
selected | Configure
|
showOutsideDays | Show days from adjacent months.
|
showWeekdayLeadBorder | Decorative left border on the first weekday column (e.g. Su).
|
showWeekNumber | Extra week-index column (ISO week of row start).
|
size | Visual density; `sm` fits popovers and tight layouts.
|
timeZone | Passed to `Intl` where supported; selection still uses local `Date` (use noon-normalized dates to avoid TZ drift).
|
value | Configure
|
weekdayLabels | If set (length 7, Sunday-first), overrides locale-derived weekday headers.
|
CalendarDateTimePanel
CalendarDateTimePanelProps
| Prop / type | Description |
|---|---|
captionLayout | Configure
|
class | Configure
|
compactWeekdays | Use two-letter weekday headers (Su–Sa).
|
defaultEndTime | Configure
|
defaultMonth | Configure
|
defaultSelected | Initial day when uncontrolled.
|
defaultStartTime | Configure
|
dir | Configure
|
disabled | Configure
|
endTime | Configure
|
endTimeLabel | Configure
|
locale | BCP 47 locale for captions and weekday labels.
|
month | Configure
|
onEndTimeChange | Configure
|
onMonthChange | Configure
|
onSelect | Configure
|
onStartTimeChange | Configure
|
selected | Selected calendar day (controlled).
|
showOutsideDays | Show days from adjacent months.
|
showWeekdayLeadBorder | Decorative line left of the first weekday; off by default.
|
size | Visual density; `sm` fits popovers and tight layouts.
|
startTime | `HH:mm` or `HH:mm:ss` for native `input[type=time]`.
|
startTimeLabel | Configure
|
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 fieldsDateRangeCalendar.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
DeclarationCalendarModeCalendar.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
DeclarationCalendarSizeCalendarSize before adapting it.CalendarDisabledProp
DeclarationCalendarDisabledPropCalendar.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 fieldsCalendarPropsCalendar.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 fieldsMonthCaptionPropsCalendar.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of MonthCaptionProps before adapting it.displayMonth, captionLayout, dir, size, onPrev, onNext, onPickMonthYearDualMonthCaption Props
9 declared fieldsDualMonthCaptionPropsCalendar.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of DualMonthCaptionProps before adapting it.firstMonth, secondMonth, dir, size, onPrev, onNextMonthGrid Props
17 declared fieldsMonthGridPropsCalendar.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of MonthGridProps before adapting it.year, month, mode, showOutsideDays, fixedWeeks, showWeekNumber, isDisabled, modifierClassesFor, hasDayAddon, size, onDayClickCalendarDateTimePanel Props
13 declared fieldsCalendarDateTimePanelPropsCalendarDateTimePanel.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.
- Choose a date using only the keyboard, including crossing month and year boundaries.
- Read selected, today and unavailable states with assistive technology rather than relying on visual styling.
- 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.
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.