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

Date Picker

Date picker combines Popover + trigger + Calendar. Use the `DatePicker` shortcut or compose `Popover`, `Button`, and `Calendar` like shadcn/ui. 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/date-picker.

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

Requires @kamod-ch/ui (includes Popover and Calendar). Optional: lucide-preact for icons in demos, chrono-node for natural-language parsing in the demo below.

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.

Usage

DatePicker wraps a styled outline Button, Popover, and single-mode Calendar with closeOnSelect. For range, dropdown month/year captions, input-adjacent pickers, or RTL, compose primitives — see Examples. Popover supports open / onOpenChange for closing after select. Calendar supports mode="single" | "range", numberOfMonths={2}, and captionLayout="dropdown".

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

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

Component Examples & Variants

Explore Date Picker 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

Own the Composition When the Workflow Needs Flexibility. Compose Popover, Button and Calendar when you need direct control over the date picker's trigger and panel. The button displays the chosen date while the calendar provides the selection interface.

Store the selected date in one place, format its display deliberately, and preserve dismissal and focus behavior when adapting the panel.

src/components/DatePickerExample.tsx1 line
// See date-picker-doc.tsx — Popover + Button + Calendar + ChevronDown

DatePicker Component

Use the Shortcut for a Standard Single-Date Field. Use the DatePicker convenience component for a standard date-selection field. Options such as triggerIcon, align and format customize common presentation needs without rebuilding the trigger, popover and calendar composition.

Check the API Reference before reaching for a custom composition, particularly when formatting, alignment or the trigger symbol is the only difference you need.

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

Calendar Icon Trigger

Make the Date Affordance Recognizable at Rest. Place a calendar icon before a left-aligned date label to make the trigger recognizable as a date field. The composed version keeps that trigger design separate from the calendar shown inside the popover.

Keep the field's actual label outside the value display and avoid making the icon a second, competing popup trigger.

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

Give the Picker the Same Structure as Other Fields. Place a labeled date trigger inside Field and let it fill the available width. The field supplies the question and supporting context, while the popover offers the calendar interaction for choosing its value.

Keep validation associated with the trigger, and distinguish an empty value from a selected date that the application no longer accepts.

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 Picker

Show a Clear Start and End Value. Use mode="range" with numberOfMonths={2} to show a period across adjacent months. The selected value represents a start and end, so the trigger should communicate both boundaries rather than a single date.

Explain inclusive or exclusive end-date rules where relevant, and verify the layout at narrow widths before adopting the wider panel.

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 of Birth

Make Distant Years Easy to Reach. Use month and year dropdowns when users commonly choose dates far from today, such as a birth date. Control open so selecting a day can close the popover after the value has been accepted.

Choose appropriate year bounds, avoid silently substituting today's date for an empty answer, and confirm that closing after selection does not prevent users from correcting a mistaken 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

With Input

Support Typing and Calendar Selection Together. Combine a typed date field with an InputGroup calendar button when people should be able to type or browse. The example also opens the calendar with Arrow Down, keeping both entry paths connected to the same value.

Handle incomplete or invalid input without silently replacing it, and preserve the keyboard shortcut for opening the calendar alongside ordinary input editing.

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

Keep Date, Time and Zone Decisions Explicit. Place a date field next to a native Input type="time" when the task requires both parts. The browser supplies time entry, while your application determines the combined value and any timezone interpretation.

Define how incomplete values and time-zone conversion are handled, and test daylight-saving boundaries when the result represents an appointment rather than a date-only record.

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

Natural Language

Show What the Phrase Resolved to. The demo uses chrono-node to interpret phrases such as “In 2 days” before displaying the resulting date. Treat that parser as an additional integration and let users review the resolved date before committing it.

Confirm the interpreted result before submission, handle unrecognized phrases, and remember that chrono-node is an additional demo dependency rather than built-in calendar behavior.

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 Date Picker 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/date-picker56.3 KB min · 13.7 KB gzipSignals: via popover@preact/signals

DatePicker

DatePickerProps

DatePicker documented props
Prop / typeDescription
align
"start" | "center" | "end"DatePickerProps

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

Default
"start"
children
ComponentChild[] | ComponentChildDatePickerProps

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

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

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

Default
—
closeOnSelect
booleanDatePickerProps

Close popover after a day is picked (single mode).

Default
true
defaultValue
DateDatePickerProps

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

Default
—
format
((date: Date) => string)DatePickerProps

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

Default
—
onValueChange
((next: Date | undefined) => void)DatePickerProps

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

Default
—
placeholder
stringDatePickerProps

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

Default
"Pick a date"
triggerIcon
"none" | "chevron" | "calendar"DatePickerProps

Trigger affordance aligned with shadcn demos.

Default
"chevron"
value
DateDatePickerProps

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

Default
—

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.

DatePicker Props

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

Accessibility

Build the Complete Interaction, Including the Parts Outside Date Picker. 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

DatePicker combines a trigger, popover and calendar, so its accessibility depends on all three. The calendar supplies day buttons; the overlay provides its dismissal behavior. Date formatting alone does not give the field a persistent accessible name.

Labels and Relationships

Associate the trigger with a visible date label and explain the accepted format or range. Keep the selected date in the trigger readable. If the variant includes text input, label that input and the calendar-opening action separately.

Keyboard and Focus

Check opening, date selection, dismissal and return focus as one flow. Escape should follow the underlying popover behavior. Do not promise Arrow Down opening for an input variant unless its actual handler implements it.

States and Integration Details

Avoid immediately submitting or navigating when a date is selected. Distinguish a malformed typed date from an unavailable date. Preserve an entered value after server rejection and state the timezone when it affects the meaning of a selected date/time.

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. Select, clear and replace a date using the keyboard, then close and reopen the picker.
  2. Test invalid input, disabled dates and a server-rejected date with an associated correction message.
  3. Verify focus return and usable calendar dimensions on a narrow screen with enlarged text.

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.