Examples
Select one date
Use a date-only value that does not shift across time zones.
Calendar with September 24 selected
"use client";
import { useState } from "react";
import { Calendar, type CalendarValue } from "@phuctech/ui/components/calendar";
export function Example() {
const [value, setValue] = useState<CalendarValue>("2026-09-24");
return <Calendar value={value} onValueChange={setValue} defaultMonth="2026-09-01" />;
}
Select a date range
Choose a start date, then an end date; the range is normalized into chronological order.
Calendar with a selected date range
"use client";
import { useState } from "react";
import { Calendar, type CalendarValue } from "@phuctech/ui/components/calendar";
export function Example() {
const [value, setValue] = useState<CalendarValue>({ from: "2026-09-14", to: "2026-09-18" });
return <Calendar mode="range" value={value} onValueChange={setValue} defaultMonth="2026-09-01" />;
}
Try the selection mode
Compare a single date with a start/end range.
Calendar selection mode playground
import { Calendar } from "@phuctech/ui/components/calendar";
export function Example() {
return <Calendar mode="single" />;
}When to use
Use Calendar as a date-selection surface or compose it inside DatePicker. Values are date-only ISO strings in YYYY-MM-DD form; they are calendar dates and are not converted between time zones. Range values use { from, to }, with either end nullable while a range is being chosen.
Usage
import { Calendar, type CalendarValue } from "@phuctech/ui/components/calendar";
const [value, setValue] = useState<CalendarValue>("2026-09-24");
<Calendar value={value} onValueChange={setValue} />API
Tokens
Accessibility
The calendar is a named group with a labeled grid. Tab enters the focused day; arrow keys move by one day or one week, Home and End move within the week, and Page Up/Down changes month (Shift changes year). Disabled dates cannot be selected, and current selection is exposed on each day.
Do and don’t
Keep date-only values as strings and apply business rules in the feature.
Convert a date-only value to midnight in a time zone; that can shift its calendar day.
Related
- DatePicker adds an input-like trigger and popover.
- TimePicker selects a local time string.