Calendar
Calendar renders date-oriented browsing and selection with month and year modes.
@duskmoon-dev/components/calendar Usage
When to use
- Use it when users need to scan structured content and act on individual records.
- Prefer it over ad hoc markup when the content has repeatable fields, hierarchy, or navigation state.
Implementation notes
Features
Designed for repeated or hierarchical content where users scan, compare, and inspect details.
Documents the props that control sorting, selection, expansion, pagination, or value changes where available.
Calendar is most often configured through `value`, `defaultValue`, `mode`, `defaultMode`.
Renders controlled value with fullscreen and custom classes
Feature Demos
Feature demos are authored for the component page, then supplemented with behavior scenarios from the component test coverage.
Basic usage
Import the component stylesheet and Calendar from its package subpath, then render it with the core props.
import "@duskmoon-dev/components/styles.css";
import { Calendar } from "@duskmoon-dev/components/calendar";
export function Example() {
return (<Calendar
value="enabled"
defaultValue="enabled"
>
DuskMoon Calendar
</Calendar>);
} Renders controlled value with fullscreen and custom classes
test-backedCalendar scenario from the component test coverage: renders controlled value with fullscreen and custom classes.
import "@duskmoon-dev/components/styles.css";
import { Calendar } from "@duskmoon-dev/components/calendar";
export function CalendarRendersControlledValueWithDemo() {
return (<Calendar
// Renders controlled value with fullscreen and custom classes
value="enabled"
defaultValue="enabled"
>
DuskMoon Calendar
</Calendar>);
} Supports uncontrolled selection callbacks
test-backedCalendar scenario from the component test coverage: supports uncontrolled selection callbacks.
import "@duskmoon-dev/components/styles.css";
import { Calendar } from "@duskmoon-dev/components/calendar";
export function CalendarSupportsUncontrolledSelectionCallbacksDemo() {
return (<Calendar
// Supports uncontrolled selection callbacks
value="enabled"
defaultValue="enabled"
>
DuskMoon Calendar
</Calendar>);
} Renders date cell content and full cell overrides
test-backedCalendar scenario from the component test coverage: renders date cell content and full cell overrides.
import "@duskmoon-dev/components/styles.css";
import { Calendar } from "@duskmoon-dev/components/calendar";
export function CalendarRendersDateCellContentDemo() {
return (<Calendar
// Renders date cell content and full cell overrides
value="enabled"
defaultValue="enabled"
>
DuskMoon Calendar
</Calendar>);
} Supports month mode and month cell render
test-backedCalendar scenario from the component test coverage: supports month mode and month cell render.
import "@duskmoon-dev/components/styles.css";
import { Calendar } from "@duskmoon-dev/components/calendar";
export function CalendarSupportsMonthModeAndDemo() {
return (<Calendar
// Supports month mode and month cell render
value="enabled"
defaultValue="enabled"
>
DuskMoon Calendar
</Calendar>);
} Emits panel changes for navigation and mode changes
test-backedCalendar scenario from the component test coverage: emits panel changes for navigation and mode changes.
import "@duskmoon-dev/components/styles.css";
import { Calendar } from "@duskmoon-dev/components/calendar";
export function CalendarEmitsPanelChangesForDemo() {
return (<Calendar
// Emits panel changes for navigation and mode changes
value="enabled"
defaultValue="enabled"
>
DuskMoon Calendar
</Calendar>);
} Blocks disabled and out-of-range dates
test-backedCalendar scenario from the component test coverage: blocks disabled and out-of-range dates.
import "@duskmoon-dev/components/styles.css";
import { Calendar } from "@duskmoon-dev/components/calendar";
export function CalendarBlocksDisabledAndOutDemo() {
return (<Calendar
// Blocks disabled and out-of-range dates
value="enabled"
defaultValue="enabled"
>
DuskMoon Calendar
</Calendar>);
} Theme aware
Docs previews inherit the DuskMoon data-theme value. Use the header switch to compare light and dark rendering.
<div data-theme="sunshine">
<Calendar
value="enabled"
defaultValue="enabled"
>
DuskMoon Calendar
</Calendar>
</div>
<div data-theme="moonlight">
<Calendar
value="enabled"
defaultValue="enabled"
>
DuskMoon Calendar
</Calendar>
</div> API
The API reference below lists every parsed exported type or interface for Calendar. Start with `value`, `defaultValue`, `mode`, `defaultMode` for common usage.
packages/components/src/components/calendar/Calendar.types.ts
Scenarios: packages/components/src/components/calendar/Calendar.test.tsx | Prop | Type | Required | Description |
|---|---|---|---|
value | CalendarValue | No | value configures Calendar. |
defaultValue | CalendarValue | No | defaultValue configures Calendar. |
mode | CalendarMode | No | mode configures Calendar. |
defaultMode | CalendarMode | No | defaultMode configures Calendar. |
fullscreen | boolean | No | fullscreen configures Calendar. |
validRange | [CalendarValue, CalendarValue] | No | validRange configures Calendar. |
disabledDate | (date: string) => boolean | No | disabledDate configures Calendar. |
dateCellRender | (date: string) => ReactNode | No | dateCellRender configures Calendar. |
dateFullCellRender | (date: string) => ReactNode | No | dateFullCellRender configures Calendar. |
monthCellRender | (date: string) => ReactNode | No | monthCellRender configures Calendar. |
monthFullCellRender | (date: string) => ReactNode | No | monthFullCellRender configures Calendar. |
cellRender | (current: string, info: CalendarInfo) => ReactNode | No | cellRender configures Calendar. |
fullCellRender | (current: string, info: CalendarInfo) => ReactNode | No | fullCellRender configures Calendar. |
headerRender | (props: CalendarHeaderRenderProps) => ReactNode | No | headerRender configures Calendar. |
onChange | (date: string) => void | No | onChange configures Calendar. |
onSelect | (date: string, selectInfo: CalendarSelectInfo) => void | No | onSelect configures Calendar. |
onPanelChange | (date: string, mode: CalendarMode) => void | No | onPanelChange configures Calendar. |
| Prop | Type | Required | Description |
|---|---|---|---|
originNode | ReactNode | Yes | originNode configures Calendar. |
today | string | Yes | today configures Calendar. |
range | "start" | "end" | No | range configures Calendar. |
type | CalendarMode | Yes | type configures Calendar. |
| Prop | Type | Required | Description |
|---|---|---|---|
source | CalendarSelectSource | Yes | source configures Calendar. |
| Prop | Type | Required | Description |
|---|---|---|---|
value | string | Yes | value configures Calendar. |
type | CalendarMode | Yes | type configures Calendar. |
onChange | (value: CalendarValue) => void | Yes | onChange configures Calendar. |
onTypeChange | (type: CalendarMode) => void | Yes | onTypeChange configures Calendar. |
"month" | "year" string | Date "date" | "month" | "year" | "customize" ForwardRefExoticComponent< CalendarProps & RefAttributes<HTMLDivElement> >