WlDatePicker
Selection
2026-10-15
Full example
<script setup lang="ts">
const props = { preview: {} as Record<string, unknown> };
import { WlDatePicker, type WlDatePickerSelectionMode, type WlDateRange } from "legato-ui";
import { computed, ref } from "vue";
const selectionMode = computed<WlDatePickerSelectionMode>(() => props.preview?.selectionMode === "range" ? "range" : "single");
const forwardedPreview = computed(() => {
const attributes = { ...props.preview };
delete attributes.selectionMode;
return attributes;
});
const single = ref<string | null>("2026-10-15");
const range = ref<WlDateRange | null>(["2026-10-15", "2026-10-20"]);
// The host app owns WlConfig: locale: wlLocaleRu retains Russian in 1.0.
// Omitted text follows that locale. Explicit range labels below belong to the app.
</script>
<template>
<div class="wl-stack" data-space="md">
<WlDatePicker
v-if="selectionMode === 'single'"
v-model="single"
selection-mode="single"
show-icon
min-date="2026-10-01"
max-date="2026-10-31"
display-format="locale"
:format-options="{ year: 'numeric', month: 'long', day: 'numeric' }"
:disabled-dates="['2026-10-18']"
aria-label="Date in October"
v-bind="forwardedPreview"
/>
<WlDatePicker
v-else
v-model="range"
selection-mode="range"
show-icon
start-label="From"
end-label="To"
min-date="2026-10-01"
max-date="2026-10-31"
display-format="locale"
:format-options="{ year: 'numeric', month: 'long', day: 'numeric' }"
:disabled-dates="['2026-10-18']"
:range-presets="[{ label: 'Week', value: ['2026-10-12', '2026-10-16'] }]"
aria-label="Dates in October"
v-bind="forwardedPreview"
/>
<p role="status">{{ selectionMode === 'range' ? JSON.stringify(range) : single ?? 'null' }}</p>
</div>
</template>Limits
2026-10-15
Full example
<script setup lang="ts">
const props = { preview: {} as Record<string, unknown> };
import { WlDatePicker, type WlDatePickerSelectionMode, type WlDateRange } from "legato-ui";
import { computed, ref } from "vue";
const selectionMode = computed<WlDatePickerSelectionMode>(() => props.preview?.selectionMode === "range" ? "range" : "single");
const forwardedPreview = computed(() => {
const attributes = { ...props.preview };
delete attributes.selectionMode;
return attributes;
});
const single = ref<string | null>("2026-10-15");
const range = ref<WlDateRange | null>(["2026-10-15", "2026-10-20"]);
// The host app owns WlConfig: locale: wlLocaleRu retains Russian in 1.0.
// Omitted text follows that locale. Explicit range labels below belong to the app.
</script>
<template>
<div class="wl-stack" data-space="md">
<WlDatePicker
v-if="selectionMode === 'single'"
v-model="single"
selection-mode="single"
show-icon
min-date="2026-10-01"
max-date="2026-10-31"
display-format="locale"
:format-options="{ year: 'numeric', month: 'long', day: 'numeric' }"
:disabled-dates="['2026-10-18']"
aria-label="Date in October"
v-bind="forwardedPreview"
/>
<WlDatePicker
v-else
v-model="range"
selection-mode="range"
show-icon
start-label="From"
end-label="To"
min-date="2026-10-01"
max-date="2026-10-31"
display-format="locale"
:format-options="{ year: 'numeric', month: 'long', day: 'numeric' }"
:disabled-dates="['2026-10-18']"
:range-presets="[{ label: 'Week', value: ['2026-10-12', '2026-10-16'] }]"
aria-label="Dates in October"
v-bind="forwardedPreview"
/>
<p role="status">{{ selectionMode === 'range' ? JSON.stringify(range) : single ?? 'null' }}</p>
</div>
</template>States
2026-10-15
Full example
<script setup lang="ts">
const props = { preview: {} as Record<string, unknown> };
import { WlDatePicker, type WlDatePickerSelectionMode, type WlDateRange } from "legato-ui";
import { computed, ref } from "vue";
const selectionMode = computed<WlDatePickerSelectionMode>(() => props.preview?.selectionMode === "range" ? "range" : "single");
const forwardedPreview = computed(() => {
const attributes = { ...props.preview };
delete attributes.selectionMode;
return attributes;
});
const single = ref<string | null>("2026-10-15");
const range = ref<WlDateRange | null>(["2026-10-15", "2026-10-20"]);
// The host app owns WlConfig: locale: wlLocaleRu retains Russian in 1.0.
// Omitted text follows that locale. Explicit range labels below belong to the app.
</script>
<template>
<div class="wl-stack" data-space="md">
<WlDatePicker
v-if="selectionMode === 'single'"
v-model="single"
selection-mode="single"
show-icon
min-date="2026-10-01"
max-date="2026-10-31"
display-format="locale"
:format-options="{ year: 'numeric', month: 'long', day: 'numeric' }"
:disabled-dates="['2026-10-18']"
aria-label="Date in October"
v-bind="forwardedPreview"
/>
<WlDatePicker
v-else
v-model="range"
selection-mode="range"
show-icon
start-label="From"
end-label="To"
min-date="2026-10-01"
max-date="2026-10-31"
display-format="locale"
:format-options="{ year: 'numeric', month: 'long', day: 'numeric' }"
:disabled-dates="['2026-10-18']"
:range-presets="[{ label: 'Week', value: ['2026-10-12', '2026-10-16'] }]"
aria-label="Dates in October"
v-bind="forwardedPreview"
/>
<p role="status">{{ selectionMode === 'range' ? JSON.stringify(range) : single ?? 'null' }}</p>
</div>
</template>Single date and start–end range
Three sizes, shared focus ring, manual ISO input, minDate/maxDate, [start,end|null] range, error, disabled and clearing.
Sizes, format and available dates
ArrowDown opens the calendar and focuses the date. Arrow keys move between days, Home/End within a week, PageUp/PageDown between months. Enter commits manual input; Escape closes the panel.
Range from start to end
The first selection stores [start, null] and keeps the calendar open. The second completes the range, sorts the dates and closes the panel. After completion, a new selection starts a new range. Clearing To preserves the start; clearing From clears everything.
Error, disabled and clearing
ISO model: 2026-10-15
Full example
<script setup lang="ts">
import { WlButton, WlDatePicker, type WlDateRange, WlField } from "legato-ui";
import { ref } from "vue";
const date = ref<string | null>("2026-10-15");
const period = ref<WlDateRange | null>(["2026-10-15", "2026-10-20"]);
</script>
<template>
<div class="wl-stack" data-space="xl" data-input-example="WlDatePicker">
<section class="wl-stack" data-space="md" aria-label="Date: format and limits">
<h3 class="wl-heading-4">{{ "Sizes, format and available dates" }}</h3>
<div class="wl-grid" data-space="lg">
<WlField
v-for="size in ['sm', 'md', 'lg'] as const"
:id="`docs-date-${size}`"
:key="size"
v-slot="{ id, ariaDescribedby }"
:label="`${'Meeting date, '}${size}`"
hint="Dates in October 2026."
><WlDatePicker
:id="id"
v-model="date"
:size="size"
show-icon
min-date="2026-10-01"
max-date="2026-10-31"
:aria-describedby="ariaDescribedby"
/></WlField>
<WlField
id="docs-date-iso"
v-slot="{ id, ariaDescribedby }"
label="Manual input in ISO format"
hint="YYYY-MM-DD; the model always remains ISO."
><WlDatePicker
:id="id"
v-model="date"
display-format="yyyy-mm-dd"
placeholder="YYYY-MM-DD"
min-date="2026-10-01"
max-date="2026-10-31"
:aria-describedby="ariaDescribedby"
/></WlField>
</div>
<p class="wl-body-sm wl-muted">{{ "ArrowDown opens the calendar and focuses the date. Arrow keys move between days, Home/End within a week, PageUp/PageDown between months. Enter commits manual input; Escape closes the panel." }}</p>
</section>
<section class="wl-stack" data-space="md" aria-label="Date range">
<h3 class="wl-heading-4">{{ "Range from start to end" }}</h3>
<WlField
id="docs-date-range"
v-slot="{ id, ariaDescribedby, invalid }"
label="Travel dates"
hint="Select start and end in one calendar or enter dates. Both limits are inclusive; dates in October 2026 are available."
:error="period && !period[1] ? 'Choose a trip end date.' : undefined"
>
<WlDatePicker
:id="id"
v-model="period"
selection-mode="range"
show-icon
name="trip-date"
start-label="From"
end-label="To"
min-date="2026-10-01"
max-date="2026-10-31"
:invalid="invalid"
:aria-describedby="ariaDescribedby"
data-testid="docs-date-range"
/>
</WlField>
<p class="wl-body-sm wl-muted">{{ "The first selection stores [start, null] and keeps the calendar open. The second completes the range, sorts the dates and closes the panel. After completion, a new selection starts a new range. Clearing To preserves the start; clearing From clears everything." }}</p>
<div class="wl-inline" data-space="sm">
<WlButton size="sm" @click="period = null">{{ "Clear range" }}</WlButton>
<WlButton size="sm" @click="period = ['2026-10-15', '2026-10-20']">{{ "Restore October 15–20" }}</WlButton>
</div>
<output
class="wl-body-sm"
aria-live="polite"
aria-label="Range model:"
data-testid="docs-date-range-model"
>{{ "Range model:" }} {{ JSON.stringify(period) }}</output>
<WlField id="docs-date-range-disabled" v-slot="{ id }" label="Unavailable range"><WlDatePicker
:id="id"
:model-value="['2026-10-15', '2026-10-20']"
selection-mode="range"
show-icon
disabled
/></WlField>
</section>
<section class="wl-stack" data-space="md" aria-label="Date: error and clearing">
<h3 class="wl-heading-4">{{ "Error, disabled and clearing" }}</h3>
<div class="wl-grid" data-space="lg">
<WlField
id="docs-date-required"
v-slot="{ id, ariaDescribedby, invalid }"
label="Required date"
:error="date ? undefined : 'Choose a meeting date.'"
><WlDatePicker
:id="id"
v-model="date"
show-icon
min-date="2026-10-01"
max-date="2026-10-31"
:invalid="invalid"
:aria-describedby="ariaDescribedby"
/></WlField>
<WlField id="docs-date-disabled" v-slot="{ id }" label="Unavailable date"><WlDatePicker
:id="id"
model-value="2026-10-15"
show-icon
disabled
/></WlField>
</div>
<div class="wl-inline" data-space="sm">
<WlButton size="sm" @click="date = null">{{ "Clear date" }}</WlButton>
<WlButton size="sm" @click="date = '2026-10-15'">{{ "Restore October 15" }}</WlButton>
</div>
<p class="wl-body-sm" role="status">{{ "ISO model:" }} {{ date ?? 'null' }}</p>
</section>
</div>
</template>Props
Types, accepted values and literal defaults come from the public manifest. Inherited settings name their source; “Not set” means no default is declared.
v-model: WlDatePickerModel<Defaults to string|null; selectionMode=range: WlDateRange|null ([start: ISO, end: ISO|null]). Completed ranges are sorted with inclusive endpoints. Clearing start → null; clearing end → [start,null].
| Prop | Type / values | Default | Purpose |
|---|---|---|---|
placeholder | string | Not set | Placeholder; falls back to WlConfig.locale.datePlaceholder (dd.mm.yyyy in English). |
size | WlSizeSm | "md" | Field size. |
disabled | boolean | false | Disables the field. |
invalid | boolean | false | Error state. |
selectionMode | Mode | "single" | single: ISO string/null; range: [start, end|null]/null. The first selection sets the start, the second completes and sorts the range, and the next starts a new one. |
startLabel | string | Not set | Visible range start label; falls back to WlConfig.locale.dateFrom (From in English). |
endLabel | string | Not set | Visible range end label; falls back to WlConfig.locale.dateTo (To in English). |
showIcon | boolean | false | Calendar icon button. |
minDate | string | Not set | Minimum date in "YYYY-MM-DD" format. Empty or invalid values do not restrict selection. |
maxDate | string | Not set | Maximum date in "YYYY-MM-DD" format. Empty or invalid values do not restrict selection. |
displayFormat | "dd.mm.yyyy" | | "dd.mm.yyyy" | Display and manual input format; the model remains ISO. |
motion | boolean | Inherits WlConfig.motion | Calendar animation; defaults to WlConfig.motion (true). |
pt | WlPt< | Not set | Attributes of internal Legato UI elements. |
density | WlDensity | "default" | Spacing density for this component family. |
formatOptions | WlDateFormatOptions | Not set | Intl date-format options used by the localized display mode. |
disabledDates | WlDisabledDates | Not set | Date list or predicate identifying dates that cannot be selected. |
rangePresets | readonly WlDateRangePreset[] | Not set | Consumer-provided predefined date ranges. |
Events
| Event | Payload | When emitted |
|---|---|---|
update:modelValue | WlDatePickerModel< | Emitted when the component requests a model change; the payload is the next value. |
Slots
No public slots.
Pass-through: pt
Sections WlDatePicker are listed below. Attributes merge in this order: createWlPt() WlConfig.ptpt instance. Class and style merge; the last supplied value takes priority for other attributes.
| Section | DOM | Purpose |
|---|---|---|
root | div.wl-dp | The root section in WlConfig.pt.datepicker configuration. |
startLabel | span.wl-dp__endpoint-label | Visible startLabel in range mode. |
inputText.root | input.wl-input | Native input that receives focus and control attributes. |
endLabel | span.wl-dp__endpoint-label | Visible endLabel in range mode. |
endInput | input.wl-input | Second text field in range mode; the first keeps inputText.root. |
dropdown | button.wl-dp__trigger | The dropdown section in WlConfig.pt.datepicker configuration. |
dropdownIcon | span.wl-dp__trigger-icon | The dropdownIcon section in WlConfig.pt.datepicker configuration. |
panel | div.wl-overlay | The panel section in WlConfig.pt.datepicker configuration. |
presets | div.wl-dp__presets | Container for the date-range preset buttons. |
preset | button.wl-dp__preset | Button that applies a completed date range. |
calendarContainer | div.wl-dp__container | The calendarContainer section in WlConfig.pt.datepicker configuration. |
calendar | div.wl-dp__calendar | The calendar section in WlConfig.pt.datepicker configuration. |
header | div.wl-dp__header | The header section in WlConfig.pt.datepicker configuration. |
prevButton.root | button.wl-dp__nav | Button that moves to the previous calendar month or view. |
prevButton.icon | span | Decorative component icon. |
title | div.wl-dp__title | The title section in WlConfig.pt.datepicker configuration. |
selectMonth | button.wl-dp__view-btn | The selectMonth section in WlConfig.pt.datepicker configuration. |
selectYear | button.wl-dp__view-btn | The selectYear section in WlConfig.pt.datepicker configuration. |
nextButton.root | button.wl-dp__nav | Button that moves to the next calendar month or view. |
nextButton.icon | span | Decorative component icon. |
rangeHint | p.wl-dp__range-hint | Current range-selection step, aria-live=polite. |
dayView | table.wl-dp__table | The dayView section in WlConfig.pt.datepicker configuration. |
tableHeaderCell | th.wl-dp__wd-cell | The tableHeaderCell section in WlConfig.pt.datepicker configuration. |
weekDay | span.wl-dp__weekday | The weekDay section in WlConfig.pt.datepicker configuration. |
dayCell | td.wl-dp__day-cell | The dayCell section in WlConfig.pt.datepicker configuration. |
day | button.wl-dp__day | The day section in WlConfig.pt.datepicker configuration. |
monthView | div.wl-dp__choices | The monthView section in WlConfig.pt.datepicker configuration. |
month | button.wl-dp__choice | The month section in WlConfig.pt.datepicker configuration. |
yearView | div.wl-dp__choices | The yearView section in WlConfig.pt.datepicker configuration. |
year | button.wl-dp__choice | The year section in WlConfig.pt.datepicker configuration. |
Sections refer to the component DOM. Dotted names identify a configuration group and its section; composite parts use their own pt groups. Global and local attributes merge, with class and style added together.
Keyboard and accessibility
- Associate the label using id/for or aria-label. In range mode, startLabel/endLabel provide visible names; the second field gets id-end/name-end and aria-describedby applies to both. The calendar button gets its name from WlConfig.
- ArrowDown opens the calendar and focuses a date; arrows move by day, Home/End by week, and PageUp/PageDown by month. Enter/Space selects a date; Escape restores focus; Tab is available for calendar navigation.
- single (default) stores YYYY-MM-DD|null. range uses WlDateRange|null: [start,end|null]. The first selection sets the start; the second completes and sorts the inclusive range; the next starts again. minDate/maxDate validate both endpoints.
- Associate invalid with error text. The ISO model format is independent of displayFormat. An empty start clears the model; an empty end leaves [start,null]. An end without a start, or an invalid or unavailable date, restores the previous display.
Keyboard and application responsibilities
| Key | Action |
|---|---|
| ← / →, ↑ / ↓ | Move by a day or a week in the open calendar. |
| Home / End | Move to a week edge. |
| PageUp / PageDown | Change the visible month. |
| Enter / Space | Choose an available day. |
| Escape | Close the date picker popup. |
Provide a meaningful accessible name and connect labels, hints and errors to the focusable element. Check the behavior with your own data and a screen reader.
WAI-ARIA Authoring PracticesChanges are emitted through v-model. After selection, cancellation and reset, labels and states must remain clear.
In your application, check keyboard controls, zoom and focus visibility. State labels and required information must be readable in every theme.