CwDateTimeRangePicker

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.

Modes and granularity

Nothing selected

Nothing selected

Nothing selected

Nothing selected

Last event: none yet

Limits, validation and locale

Between 30 days ago and today

Future dates allowed (maxDate={null})

Nothing selected

Choose a report period

Nothing selected

CwDateTimeRangePicker example Copy code
<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} />
API

Usage and API reference

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.

How to think about it

  1. Choose single or range mode first Single mode returns `{ date }`, while range mode returns `{ start, end }`. That choice drives the value shape for the rest of the form.
  2. Pick the granularity that matches the report Use `day` for exact dates, `month` for monthly rollups, and `year` for broad reporting periods.
  3. Enable time only when the workflow needs it Including time adds more controls, more value fields, and explicit Set/Cancel confirmation, so keep it off for date-only filters.

Props and callbacks

APITypeDetails
mode

Default: single

'single' | 'range'Controls whether the component returns one date or a date range.
granularity

Default: day

'year' | 'month' | 'day'Controls the picker depth.
includeTime

Default: false

booleanAdds time selection, along with Set/Cancel controls, to the returned value.
value
CwDateValue | undefinedCurrent selected date or range.
maxDate

Default: new Date()

DateLatest selectable date.
onchange
(value: CwDateValue) => voidRuns whenever a valid selection is emitted.
name / required / placeholder / autocomplete
native attrsOptional form integration attributes for the visible trigger input.
label
stringVisible label above the trigger.
id
stringId for the trigger, for external labels.
hint
stringHelper text under the field. Replaced by `error` when both are set.
error
stringError message under the field. Sets `aria-invalid` and links the text with `aria-describedby`.
required

Default: false

booleanShows a required marker and sets `aria-required` on the control.
disabled

Default: false

booleanDisables the trigger.
minDate
Date | nullEarliest selectable date.
locale
stringBCP 47 locale for number and date formatting. Defaults to the runtime locale.

Copy-paste examples

Each snippet is a complete, working example you can paste into a Svelte 5 component.

Single month picker

Good for monthly reports or billing cycles.

Single month picker Copy code
<script lang="ts">
	let monthValue = $state<CwDateValue | undefined>();
</script>

<CwDateTimeRangePicker
	mode="single"
	granularity="month"
	bind:value={monthValue}
/>
Range picker with time

Use this for precise reporting windows or scheduled operations.

Range picker with time Copy code
<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)}
/>