Single month picker
Good for monthly reports or billing cycles.
<script lang="ts">
let monthValue = $state<CwDateValue | undefined>();
</script>
<CwDateTimeRangePicker
mode="single"
granularity="month"
bind:value={monthValue}
/>Single dates or ranges at day, month or year granularity, with optional time. The calendar grid is
keyboard-operable (arrows, Home/End, PageUp/PageDown, Shift+Page for years) and month and weekday
names follow the locale.
Nothing selected
Nothing selected
Nothing selected
Nothing selected
Last event: none yet
Nothing selected
Nothing selected
<CwDateTimeRangePicker
label="Report period"
mode="range"
granularity="day"
includeTime
required
minDate={thirtyDaysAgo}
bind:value
/>
<!-- maxDate defaults to today; pass null to allow future dates -->
<CwDateTimeRangePicker label="Harvest date" maxDate={null} bind:value={harvest} />CwDateTimeRangePicker covers single dates, ranges, month and year picking, and optional time entry. The returned value shape changes with `mode`, so decide that up front.
| API | Type | Details |
|---|---|---|
mode Default: | 'single' | 'range' | Controls whether the component returns one date or a date range. |
granularity Default: | 'year' | 'month' | 'day' | Controls the picker depth. |
includeTime Default: | boolean | Adds time selection, along with Set/Cancel controls, to the returned value. |
value | CwDateValue | undefined | Current selected date or range. |
maxDate Default: | Date | Latest selectable date. |
onchange | (value: CwDateValue) => void | Runs whenever a valid selection is emitted. |
name / required / placeholder / autocomplete | native attrs | Optional form integration attributes for the visible trigger input. |
label | string | Visible label above the trigger. |
id | string | Id for the trigger, for external labels. |
hint | string | Helper text under the field. Replaced by `error` when both are set. |
error | string | Error message under the field. Sets `aria-invalid` and links the text with `aria-describedby`. |
required Default: | boolean | Shows a required marker and sets `aria-required` on the control. |
disabled Default: | boolean | Disables the trigger. |
minDate | Date | null | Earliest selectable date. |
locale | string | BCP 47 locale for number and date formatting. Defaults to the runtime locale. |
Each snippet is a complete, working example you can paste into a Svelte 5 component.
Good for monthly reports or billing cycles.
<script lang="ts">
let monthValue = $state<CwDateValue | undefined>();
</script>
<CwDateTimeRangePicker
mode="single"
granularity="month"
bind:value={monthValue}
/>Use this for precise reporting windows or scheduled operations.
<script lang="ts">
let rangeValue = $state<CwDateValue | undefined>();
</script>
<CwDateTimeRangePicker
mode="range"
granularity="day"
includeTime
name="report-window"
required
placeholder="Select report window..."
maxDate={new Date()}
bind:value={rangeValue}
onchange={(value) => console.log(value)}
/>