DatePicker / RangePicker
Date, time and associated ranges with restrictions and confirmation.
When to use
DatePicker selects a calendar date via an input field and a calendar. showTime adds time to the same date. RangePicker selects the associated start and end of a period in a common pane. For times without a calendar, use TimePicker.
Both components let you select a day, week, month, quarter or year. Switch the period unit to see how the field and calendar change.
Meaning and input
The standard DatePicker stores Dayjs | null, and RangePicker stores a pair of endpoints or null. The field text and the event's dateString are display values.
| Problem | Setting | Example |
|---|---|---|
| Select day | value, onChange |
Base date |
| Select a week, month, quarter or year | picker |
Reporting period |
| Accept multiple input formats | Array format |
Formats and erroneous input |
| Enter a date one part at a time | A format object with type: 'mask' |
Date input mask |
| Select date with time | showTime |
Date and time |
| Select start and end | RangePicker |
Date range |
Store Dayjs in a form |
form.setFieldValue |
Date in Form |
For a managed field, pass value and take the result of onChange into the Svelte state. Clearing returns null. defaultValue specifies the initial local selection. defaultPickerValue sets the initial date of the panel when opened and does not fill in value; pickerValue controls the date shown separately from the picker.
Multiple selection returns an array of dates. It supports days, weeks, months, quarters and years. With needConfirm the draft is committed on OK. Time selection is available for a single date or a range.
Months, quarters and years have their own display formats, such as 2026-05, 2026-Q2 and 2026. Each mode returns a Dayjs value. If a report needs the first day of a period, calculate it explicitly. A selected quarter can retain a date inside that quarter.
With picker="week", the field displays the week year and number. The default format is gggg-wo. The calendar locale determines the first day of the week and how weeks are numbered. For example, Sunday, January 4, 2026 falls in week two in the US English locale and week one in the Russian and Chinese locales.
Select a day to keep that exact date in the Dayjs value. Select a week number to use the first day of its row. Week numbers are visible by default when picking weeks. In the day picker, turn them on with showWeek and continue selecting individual dates.
The first element of the format array determines how the date is displayed and sets the initial field width. String formats define the accepted input. The format example accepts DD.MM.YYYY and YYYY-MM-DD. If the first element is a function, the field is readonly.
To enter a date one part at a time, pass format={{ format: 'YYYY-MM-DD', type: 'mask' }}. Without type, the object acts like a plain format string. The mask recognizes YYYY, MM, DD, HH, mm, ss and SSS. Use the left and right arrows to select the year, month or day. The up and down arrows change the selected part. Press Enter to confirm a complete date. In the range example, each field accepts both a date and a time.
An incomplete or invalid date leaves the accepted value intact. By default, the field shows the accepted date again after the panel closes. Set preserveInvalidOnBlur to keep the text you entered. In DatePicker and RangePicker, aria-invalid stays set while the field displays preserved invalid text. To restrict selection to the calendar, use a plain format string with inputReadOnly. Masked fields still accept keyboard edits.
Custom editor
To use a textarea styled like the picker field, set input: 'textarea' in components. The built-in editor fits the field width and uses the theme's colors and font.
In the date fields example, one Svelte snippet renders a textarea for the date and each range endpoint. The example supplies its own editor styles. The editor context provides range so each endpoint can have its own accessible name.
Forward attributes to the element and attach {@attach register}. For a textarea, pass value separately so the initial value is visible before JavaScript runs. Enter commits the date. At the start of a range, it also moves focus to the end field. In multiple mode, DatePicker uses its built-in field.
Set autoFocus to focus the field when it appears. A range focuses the first enabled field. Use tabIndex to set the tab order and autoComplete to control browser autocomplete. The focus example shows the field after a button press. Fields using a date adapter created with generatePicker also support these props.
Confirmation and limitations
A single click selects a day, week, month, quarter or year. Set needConfirm to accept the choice with OK. Confirmation is enabled by default when picking a day with showTime. In the confirmation example, onCalendarChange shows the draft and onChange reports the accepted value. Press Escape in the input to discard an unconfirmed change.
When the selection changes, OK calls onOk, then onChange and onOpenChange(false). In the example, the app accepts the date and closes the panel inside onOk. The remaining callbacks still run in order. Pressing Enter after typing a valid date commits it without calling onOk.
Try choosing the minutes first in the empty date and time example. The date comes from the open calendar. The initial time comes from showTime.defaultOpenValue and defaults to midnight. Each end of a range has its own initial time. Use showTime to configure the time columns, change their steps or hide unavailable times. The field’s own format controls how the selected date and time appear in the input.
When selecting a cell changes both the draft and the panel date, onCalendarChange runs before onPickerValueChange with source: 'panel'. If reopening the picker resets the panel date, onOpenChange(true) runs before the notification with source: 'reset'.
Use minDate and maxDate to limit date selection and calendar navigation. Both bounds are inclusive. In the restrictions example, disabledDate excludes weekends. With showTime enabled, disabledTime limits the choice to working hours.
When picking a week, you can select any day of the week containing minDate or maxDate. With both bounds set to January 1, 2026, the Russian and Chinese locales allow December 29 through January 4. In the US English locale, the available week runs from December 28 through January 3.
In the range, disabledDate gets info.from and disabledTime gets partial=start/end and info.from. Seven day period limits the second boundary relative to the first. Set Form validation rules separately from the visual status field.
Range and ready periods
RangePicker accepts a pair of Dayjs with possible empty borders. The allowEmpty property allows a specific border to be left blank; disabled disables editing it. These settings solve different problems. Open range stores the start date without necessarily ending.
When confirming a range, onOk runs for each available endpoint. After the available endpoints are confirmed, onChange publishes the changed pair. The active field needs a valid date to enable OK, even with allowEmpty.
order sorts the endpoints. onCalendarChange reports the active endpoint through info.range. Clearing the range returns null.
Pass a list of shortcuts to presets. Each has a label and a value: a date, a pair of range dates, or a function returning the appropriate value. A function works well for dates relative to today. Hovering previews the date in the field before selection. Set previewValue={false} to turn the preview off. Try the end of the current month or a preset range.
The same example uses prevIcon and nextIcon for the previous and next month arrows. Use superPrevIcon and superNextIcon for larger jumps. The picker supplies the navigation buttons' names and actions.
period form stores Dayjs objects. Conversion to a calendar string or ISO, time zone selection, and request preparation are performed by the application upon submission. The field format itself does not define this policy.
Custom panel
In the slider example, components.date supplies the day panel. onPickerValueChange updates the date in view, disabledDate checks availability, and onSelect passes the selected day to the picker.
Set the panel by its mode key. The supported keys are date, week, month, quarter, year, decade, time and datetime. datetime replaces the calendar and time columns together. The built-in panel opens for other modes. Each of the two RangePicker panels receives its own pickerValue. range identifies the active endpoint.
Language and design
suffixIcon sets the trailing content of DatePicker and RangePicker. ConfigProvider.datePicker.suffixIcon supplies the default; a local prop takes priority. Values of undefined and true display the calendar together with Form feedback; null, false and '' hide the suffix. A custom snippet or content replaces the entire suffix, including feedback. The icon example demonstrates provider settings and a local override.
ConfigProvider with ruRU/enUS sets the interface dictionary; local locale.lang allows you to change a single field. For another language, also download the appropriate Day.js locale. One global dayjs.locale does not replace the component's dictionary. Localization example shows independent Russian and English calendars.
Both components inherit ConfigProvider.prefixCls with the -picker suffix. A non-empty local prefixCls specifies the full name of the field, calendar and time bar; empty string/undefined return the general prefix. The OK button independently uses the common Button prefix. CSS date prefixes also show RTL and a separate theme.cssVar.prefix.
Changing the prefix preserves the DOM, focus, selection, erroneous text and unconfirmed time in the open panel. This is not a replacement for changing value or format: the new data and format updates the displayed text. The design works without CSS variables, including the dark and compact theme. The prefix/suffix color service variable uses the common provider prefix without dots; The theme variable namespace and canonical area markers remain separate settings.
To mark the first of each month, wrap info.originNode() in cellRender. The standard button retains focus handling, keyboard selection and disabled dates. For time cells, info.subType identifies the column. In a range, info.range identifies the boundary being edited on either panel.
Use panelRender to add a heading above the calendar and presets. Render the supplied snippet where the standard panel should appear. For a hint below the calendar, use renderExtraFooter. Its snippet receives the current panel mode.
In the placement example, DatePicker and RangePicker share styles through ConfigProvider.datePicker. Use classNames and styles for the field, prefix, suffix and panel parts. For colors and sizes, see design tokens. See also the API and example coverage.
Use builtinPlacements to set the entire placement map and popupAlign to override fields for the selected placement. In the range example, points: ['tl', 'bl'] aligns the top-left corner of the panel with the bottom-left corner of the field. The offset sets a 12 px gap. If the panel is already open, changes to a placement in the map take effect at the next measurement, such as on scroll.
The field needs an accessible name via label or aria-label. Arrows move focus around the calendar, Enter selects a date, Escape closes the panel. The focus/blur methods are accessible via the instance; local getPopupContainer takes precedence over ConfigProvider.
Use your own date type
If your application stores dates in its own type, create a family of fields with DatePicker.generatePicker(adapter). Define calendar operations, week rules, formatting and parsing in GenerateConfig<DateType>. Use the adapter's date type for values, presets and limits. The onChange callback returns selected dates in that same type. In a Svelte template, the adapter determines the type of the RangePicker endpoints and the first onChange argument.
The family includes WeekPicker, MonthPicker, YearPicker, TimePicker and RangePicker. Set picker="quarter" to select a quarter. You can also import the factory as generatePicker.
In the JavaScript Date example, the model stores plain Date objects, and the adapter uses Day.js for calculations in UTC. The example source includes both fields and the adapter.
Examples
Base date
Calendar selection or manual entry. value is stored as Dayjs | null; onChange accepts a new object.
<script lang="ts">
import dayjs, { type Dayjs } from 'dayjs';
import { Checkbox, DatePicker } from '@woodger/antd';
let value = $state<Dayjs | null>(null);
let showWeek = $state(false);
</script>
<style>
.example {
display: grid;
gap: 16px;
}
output {
overflow-wrap: anywhere;
}
</style>
<div class="example">
<Checkbox bind:checked={showWeek}>{("Show week numbers")}</Checkbox>
<DatePicker
aria-label={("Base date")}
{value}
{showWeek}
defaultPickerValue={dayjs('2026-10-15')}
onChange={next => { value = next; }}
/>
<output aria-label={("Selected base date")}>{(value?.format('YYYY-MM-DD') ?? 'null')}</output>
</div>
Multiple dates
Pick several dates in one calendar. Each selected date appears as a tag.
<script lang="ts">
import { Checkbox, DatePicker } from '@woodger/antd';
import dayjs, { type Dayjs } from 'dayjs';
const month = dayjs('2026-10-01');
let dates = $state.raw<Dayjs[] | null>([month.date(5), month.date(12)]);
let confirm = $state(false);
</script>
<div class="example">
<Checkbox bind:checked={confirm}>{("Confirm selection")}</Checkbox>
<DatePicker
multiple
value={dates}
defaultPickerValue={month}
needConfirm={confirm}
maxTagCount="responsive"
aria-label={("Selected dates")}
onChange={next => dates = next}
/>
<output aria-label={("Selected dates")}>
{dates?.map(date => date.format('YYYY-MM-DD')).join(', ') || '—'}
</output>
</div>
<style>
.example {
display: grid;
gap: 12px;
max-width: 320px;
}
</style>
Controlled panels
The field requests a transition through onPanelChange. A range keeps a separate mode for each endpoint.
<script lang="ts">
import { DatePicker, RangePicker, type DatePickerMode, type RangePickerMode } from '@woodger/antd';
import dayjs from 'dayjs';
const month = dayjs('2026-10-01');
let mode = $state<DatePickerMode>('year');
let modes = $state.raw<RangePickerMode>(['month', 'year']);
</script>
<div class="example">
<DatePicker
{mode}
defaultPickerValue={month}
aria-label={("Date with a controlled panel")}
onPanelChange={(_, next) => mode = next}
/>
<output aria-label={("Panel mode")}>{mode}</output>
<RangePicker
mode={modes}
defaultPickerValue={month}
placeholder={(["Range start", "Range end"])}
onPanelChange={(_, next) => modes = next}
/>
<output aria-label={("Range endpoint modes")}>{modes.join(' / ')}</output>
</div>
<style>
.example {
display: grid;
gap: 12px;
max-width: 360px;
}
</style>
Date range
Choose the start and end in one calendar. The fields show the two ends of the range.
<script lang="ts">
import dayjs from 'dayjs';
import { RangePicker, type RangePickerValue } from '@woodger/antd';
let value = $state<RangePickerValue | null>(null);
</script>
<style>
.example {
display: grid;
gap: 16px;
}
output {
overflow-wrap: anywhere;
}
</style>
<div class="example">
<RangePicker {value} style="width:100%" defaultPickerValue={dayjs('2026-10-15')}
placeholder={(["Start of base range", "End of base range"])}
onChange={next => { value = next; }} />
<output aria-label={("Basic range")}>{(value?.map(
date => date?.format('YYYY-MM-DD') ?? '—'
).join(' — ') ?? 'null')}</output>
</div>
Date and range with JavaScript Date
Choose a delivery date or window in UTC. The model stores Date objects.
NativeDatePickers.svelte<script lang="ts"> import { DatePicker, Flex, type RangePickerValue } from '@woodger/antd'; import { nativeDateAdapter } from './native-date-adapter'; const NativeDatePicker = DatePicker.generatePicker(nativeDateAdapter); const { RangePicker } = NativeDatePicker; const initialDate = new Date('2026-10-15T00:00:00Z'); let deliveryDate = $state<Date | null>(initialDate); let deliveryRange = $state.raw<RangePickerValue<Date> | null>(null); const [start, end] = $derived(deliveryRange ?? [null, null]); </script> <Flex vertical gap="medium"> <Flex vertical gap="small" align="start"> <NativeDatePicker aria-label={("Delivery date in UTC")} value={deliveryDate} onChange={next => { deliveryDate = next; }} /> <output aria-label={("Stored delivery date")}> {deliveryDate?.toISOString() ?? '—'} </output> </Flex> <Flex vertical gap="small"> <RangePicker value={deliveryRange} defaultPickerValue={initialDate} placeholder={(["Delivery start", "Delivery end"])} onChange={next => { deliveryRange = next; }} /> <output aria-label={("Stored delivery window")}> {start?.toISOString() ?? '—'} – {end?.toISOString() ?? '—'} </output> </Flex> </Flex>native-date-adapter.tsimport type { GenerateConfig } from '@woodger/antd'; import dayjs from 'dayjs'; import customParseFormat from 'dayjs/plugin/customParseFormat.js'; import localeData from 'dayjs/plugin/localeData.js'; import utc from 'dayjs/plugin/utc.js'; import weekOfYear from 'dayjs/plugin/weekOfYear.js'; import 'dayjs/locale/de.js'; import 'dayjs/locale/es.js'; import 'dayjs/locale/fr.js'; import 'dayjs/locale/pt-br.js'; import 'dayjs/locale/ru.js'; import 'dayjs/locale/zh-cn.js'; dayjs.extend(customParseFormat); dayjs.extend(localeData); dayjs.extend(utc); dayjs.extend(weekOfYear); const dayjsLocales: Record<string, string> = { de_DE: 'de', en_US: 'en', es_ES: 'es', fr_FR: 'fr', pt_BR: 'pt-br', ru_RU: 'ru', zh_CN: 'zh-cn' }; function localizedDate(locale: string, value = new Date()) { const language = dayjsLocales[locale] ?? 'en'; return dayjs.utc(value).locale(language); } function parseDate(_locale: string, text: string, formats: string[]): Date | null { for (const format of formats) { const parsed = dayjs.utc(text, format, true); if (parsed.isValid()) { return parsed.toDate(); } } return null; } export const nativeDateAdapter: GenerateConfig<Date> = { getNow: () => new Date(), getFixedDate: text => dayjs.utc(text).toDate(), getEndDate: date => dayjs.utc(date).endOf('month').toDate(), getWeekDay: date => date.getUTCDay(), getYear: date => date.getUTCFullYear(), getMonth: date => date.getUTCMonth(), getDate: date => date.getUTCDate(), getHour: date => date.getUTCHours(), getMinute: date => date.getUTCMinutes(), getSecond: date => date.getUTCSeconds(), getMillisecond: date => date.getUTCMilliseconds(), addYear: (date, amount) => dayjs.utc(date).add(amount, 'year').toDate(), addMonth: (date, amount) => dayjs.utc(date).add(amount, 'month').toDate(), addDate: (date, amount) => dayjs.utc(date).add(amount, 'day').toDate(), setYear: (date, year) => dayjs.utc(date).year(year).toDate(), setMonth: (date, month) => dayjs.utc(date).month(month).toDate(), setDate: (date, day) => dayjs.utc(date).date(day).toDate(), setHour: (date, hour) => dayjs.utc(date).hour(hour).toDate(), setMinute: (date, minute) => dayjs.utc(date).minute(minute).toDate(), setSecond: (date, second) => dayjs.utc(date).second(second).toDate(), setMillisecond: (date, millisecond) => dayjs.utc(date).millisecond(millisecond).toDate(), isAfter: (first, second) => first.getTime() > second.getTime(), isValidate: date => Number.isFinite(date.getTime()), locale: { getWeekFirstDay: locale => localizedDate(locale).localeData().firstDayOfWeek(), getWeekFirstDate: (locale, date) => localizedDate(locale, date).startOf('week').toDate(), getWeek: (locale, date) => localizedDate(locale, date).week(), getShortWeekDays: locale => localizedDate(locale).localeData().weekdaysMin(), getShortMonths: locale => localizedDate(locale).localeData().monthsShort(), format: (locale, date, format) => localizedDate(locale, date).format(format), parse: parseDate } };
Day, week, month, quarter and year
Switch the unit for both the single picker and the range picker.
<script lang="ts">
import { DatePicker, RadioGroup, RangePicker, type DatePickerPicker } from '@woodger/antd';
import dayjs from 'dayjs';
const initialDate = dayjs('2026-01-01');
let picker = $state<DatePickerPicker>('quarter');
</script>
<div class="example">
<RadioGroup
aria-label={("Period unit")}
optionType="button"
value={picker}
options={([
{ value: 'date', label: "Day" },
{ value: 'week', label: "Week" },
{ value: 'month', label: "Month" },
{ value: 'quarter', label: "Quarter" },
{ value: 'year', label: "Year" }
] as const)}
onValueChange={next => { picker = next; }}
/>
<DatePicker
{picker}
aria-label={("Reporting period")}
defaultValue={initialDate}
/>
<RangePicker
{picker}
defaultPickerValue={initialDate}
placeholder={(["Reporting period start", "Reporting period end"])}
/>
</div>
<style>
.example {
display: grid;
gap: 16px;
min-width: 0;
}
</style>
Confirm selection
Choose a date and click OK to see the order of confirmation callbacks.
<script lang="ts">
import { DatePicker } from '@woodger/antd';
import dayjs, { type Dayjs } from 'dayjs';
const initialMonth = dayjs('2026-10-15');
let value = $state<Dayjs | null>(null);
let open = $state(false);
let draft = $state('—');
let events = $state<string[]>([]);
function confirmDate(next: Dayjs) {
events.push('onOk');
value = next;
open = false;
}
function changeDate(next: Dayjs | null) {
value = next;
events.push('onChange');
}
function changeOpen(next: boolean) {
open = next;
if (next) {
events = [];
}
else {
events.push('onOpenChange(false)');
}
}
</script>
<style>
.example {
display: grid;
gap: 16px;
}
output {
overflow-wrap: anywhere;
}
</style>
<div class="example">
<DatePicker
aria-label={("Date with confirmation")}
{value}
{open}
needConfirm
defaultPickerValue={initialMonth}
onCalendarChange={next => { draft = next?.format('YYYY-MM-DD') ?? '—'; }}
onOk={confirmDate}
onChange={changeDate}
onOpenChange={changeOpen}
/>
<output
aria-label={("Date confirmation")}
>{("Draft: ")}{draft}{("; meaning: ")}{(value?.format('YYYY-MM-DD') ?? 'null')}</output>
<output aria-label={("Date confirmation events")}>
{events.join(' → ') || '—'}
</output>
</div>
Formats and erroneous input
The first format specifies the output, the rest are accepted upon input. preserveInvalidOnBlur preserves erroneous text without turning it into a date.
<script lang="ts">
import { DatePicker } from '@woodger/antd';
import dayjs, { type Dayjs } from 'dayjs';
const displayFormat = 'DD.MM.YYYY';
let value = $state<Dayjs | null>(dayjs('2026-10-15'));
</script>
<style>
.example {
display: grid;
gap: 16px;
}
</style>
<div class="example">
<DatePicker aria-label={("Multiple date formats")} {value} format={[
displayFormat,
'YYYY-MM-DD'
]}
onChange={next => { value = next; }} />
<output aria-label={("Date after parsing")}>{(value?.format('YYYY-MM-DD') ?? 'null')}</output>
<DatePicker
aria-label={("Saving erroneous input")}
defaultValue={dayjs('2026-10-15')}
format={displayFormat}
preserveInvalidOnBlur
/>
</div>
Date input mask
Enter the year, month and day. For a range, also enter the time at each endpoint.
<script lang="ts">
import { DatePicker, RangePicker } from '@woodger/antd';
import type { Dayjs } from 'dayjs';
let date = $state<Dayjs | null>(null);
</script>
<div class="example">
<DatePicker
aria-label={("Masked date")}
format={{ format: 'YYYY-MM-DD', type: 'mask' }}
value={date}
onChange={next => { date = next; }}
/>
<output aria-label={("Confirmed date")}>{date?.format('YYYY-MM-DD') ?? '—'}</output>
<RangePicker
format={{ format: 'DD.MM.YYYY HH:mm', type: 'mask' }}
showTime={{ format: 'HH:mm' }}
placeholder={(["Masked start date and time", "Masked end date and time"])}
/>
</div>
<style>
.example {
display: grid;
gap: 16px;
min-width: 0;
}
</style>
Custom date fields
Enter a delivery date or a date range. Enter confirms the input. The first editor displays the latest focus or keyboard event.
<script lang="ts">
import {
DatePicker, RangePicker, type DatePickerEditorContext, type RangePickerValue
} from '@woodger/antd';
import dayjs from 'dayjs';
const id = $props.id();
const periodId = id + '-period';
const delivery = dayjs('2026-10-15');
const period: RangePickerValue = [delivery, delivery.add(5, 'day')];
const labels = {
start: ("Delivery window start"),
end: ("Delivery window end")
};
let lastEvent = $state('');
</script>
{#snippet editor({ attributes, register, range }: DatePickerEditorContext)}
{@const { value, defaultValue, type, size, ...textareaAttributes } = attributes}
<textarea
{...textareaAttributes}
{value}
rows={1}
aria-label={range ? labels[range] : attributes['aria-label']}
{@attach register}
></textarea>
{/snippet}
<div class="example">
<div class="field">
<label for={id}>{("Delivery date")}</label>
<DatePicker
{id}
components={{ input: editor }}
defaultValue={delivery}
previewValue={false}
onFocus={() => { lastEvent = 'onFocus'; }}
onBlur={() => { lastEvent = 'onBlur'; }}
onKeyDown={event => { lastEvent = 'onKeyDown: ' + event.key; }}
/>
</div>
<output aria-label={("Latest event")}>{lastEvent || ("No events")}</output>
<div class="field" role="group" aria-labelledby={periodId}>
<span id={periodId}>{("Delivery window")}</span>
<RangePicker
components={{ input: editor }}
defaultValue={period}
placeholder={[labels.start, labels.end]}
previewValue={false}
/>
</div>
</div>
<style>
.example {
display: grid;
gap: 16px;
max-width: 360px;
}
.field {
display: grid;
gap: 4px;
min-width: 0;
}
textarea {
flex: 1;
box-sizing: border-box;
min-width: 0;
width: 100%;
padding: 0;
border: 0;
background: transparent;
color: inherit;
font: inherit;
resize: none;
}
</style>
Focus when the field appears
Click “Set date” to show and focus the field.
<script lang="ts">
import { Button, DatePicker, Flex } from '@woodger/antd';
let shown = $state(false);
</script>
<Flex vertical gap="small" align="start">
<Button aria-expanded={shown} onclick={() => { shown = !shown; }}>
{shown ? ("Hide field") : ("Set date")}
</Button>
{#if shown}
<DatePicker
aria-label={("Delivery date")}
autoFocus
tabIndex={0}
autoComplete="off"
/>
{/if}
</Flex>
Date and time
showTime adds time to a single date and range. defaultOpenValue sets the initial time of the panel; each end is confirmed separately.
<script lang="ts">
import dayjs, { type Dayjs } from 'dayjs';
import { DatePicker, RangePicker, type RangePickerValue } from '@woodger/antd';
let date = $state<Dayjs | null>(null);
let range = $state<RangePickerValue | null>(null);
</script>
<style>
.example {
display: grid;
gap: 16px;
}
output {
overflow-wrap: anywhere;
}
</style>
<div class="example">
<DatePicker aria-label={("Date and time")} value={date} format="YYYY-MM-DD HH:mm"
defaultPickerValue={dayjs('2026-10-15')} showNow={false}
showTime={{ format: 'HH:mm', minuteStep: 15, defaultOpenValue: dayjs('2000-01-01T09:00') }}
onChange={next => { date = next; }} />
<output aria-label={("Date and time result")}>{(date?.format('YYYY-MM-DD HH:mm') ?? 'null')}</output>
<RangePicker
value={range}
style="width:100%"
format="DD.MM.YYYY HH:mm"
showNow={false}
placeholder={(["Starting with time", "The end with time"])}
defaultPickerValue={dayjs('2026-10-15')}
showTime={{
format: 'HH:mm', minuteStep: 30, defaultOpenValue: [
dayjs('2000-01-01T09:00'),
dayjs('2000-01-01T18:00')
]
}}
onChange={next => { range = next; }}
/>
<output aria-label={("Range over time")}>{(range?.map(
date => date?.format('YYYY-MM-DD HH:mm') ?? '—'
).join(' — ') ?? 'null')}</output>
</div>
Limits of available dates
minDate/maxDate limits the selection from October 10 to October 20, 2026 and panel transitions.
<script lang="ts">
import dayjs from 'dayjs';
import { DatePicker } from '@woodger/antd';
</script>
<DatePicker
aria-label={("Date within October")}
defaultPickerValue={dayjs('2026-10-15')}
minDate={dayjs('2026-10-10')}
maxDate={dayjs('2026-10-20')}
/>
Inaccessible fields
A single field can be disabled entirely, while a RangePicker can have only one border via the disabled array.
<script lang="ts">
import dayjs from 'dayjs';
import { DatePicker, RangePicker } from '@woodger/antd';
</script>
<style>
.example {
display: grid;
gap: 16px;
}
</style>
<div class="example">
<DatePicker
aria-label={("Unavailable date")}
defaultValue={dayjs('2026-10-15')}
disabled
/>
<RangePicker style="width:100%" disabled={[true, false]}
defaultValue={[dayjs('2026-10-15'), dayjs('2026-10-20')]}
placeholder={(["Blocked start", "Accessible end"])} />
</div>
Date and time restrictions
Weekends are excluded via disabledDate, hours outside of working hours – via disabledTime. The time limit works in conjunction with showTime.
<script lang="ts">
import dayjs from 'dayjs';
import { DatePicker } from '@woodger/antd';
</script>
<DatePicker
aria-label={("Working date and time")}
defaultPickerValue={dayjs('2026-10-15')}
format="YYYY-MM-DD HH:mm"
showNow={false}
showTime={{ format: 'HH:mm', minuteStep: 30, defaultOpenValue: dayjs('2026-10-15T09:00') }}
disabledDate={date => date.day() === 0 || date.day() === 6}
disabledTime={() => ({
disabledHours: () => [
...Array.from({ length: 9 }, (_, hour) => hour),
18,
19,
20,
21,
22,
23
]
})}
/>
Optional border
allowEmpty=[false, true] allows the absence of an end while preserving the required beginning.
<script lang="ts">
import dayjs from 'dayjs';
import { RangePicker, type RangePickerValue } from '@woodger/antd';
let value = $state<RangePickerValue | null>([dayjs('2026-10-15'), null]);
</script>
<style>
.example {
display: grid;
gap: 16px;
}
output {
overflow-wrap: anywhere;
}
</style>
<div class="example">
<RangePicker {value} allowEmpty={[false, true]} style="width:100%"
placeholder={(["Start date without deadline", "No deadline specified"])}
onChange={next => { value = next; }} />
<output aria-label={("Open range")}>{(value?.map(
date => date?.format('YYYY-MM-DD') ?? "no deadline"
).join(' — ') ?? 'null')}</output>
</div>
No more than seven days
disabledDate receives info.from and limits the second selection to six days from the first: together with the start, the result is seven calendar days.
<script lang="ts">
import dayjs from 'dayjs';
import { RangePicker } from '@woodger/antd';
</script>
<RangePicker style="width:100%" defaultPickerValue={dayjs('2026-10-15')}
placeholder={(["Start of seven day period", "End of seven day period"])}
disabledDate={(date, { from }) => !!from && Math.abs(date.startOf('day').diff(
from.startOf('day'),
'day'
)) > 6} />
Finished periods
Static range and function that calculates dates at the time of selection. Guidance shows the preliminary range without changing the model.
<script lang="ts">
import dayjs from 'dayjs';
import { RangePicker, type RangePickerValue } from '@woodger/antd';
let value = $state<RangePickerValue | null>(null);
</script>
<style>
.example {
display: grid;
gap: 16px;
}
output {
overflow-wrap: anywhere;
}
</style>
<div class="example">
<RangePicker {value} style="width:100%" defaultPickerValue={dayjs('2026-10-15')}
placeholder={(["Start of the finished period", "End of the finished period"])}
presets={([
{ label: "Working week", value: [dayjs('2026-10-19'), dayjs('2026-10-23')] },
{
label: "Next three days", value: () => [
dayjs().startOf('day'),
dayjs().add(2, 'day').startOf('day')
]
}
])}
onChange={next => { value = next; }} />
<output aria-label={("Finished period")}>{(value?.map(
date => date?.format('YYYY-MM-DD') ?? '—'
).join(' — ') ?? 'null')}</output>
</div>
First day of the month
A circle marks the first of each month. Select dates with the mouse or keyboard.
<script lang="ts">
import { DatePicker, RangePicker, type DatePickerCellRenderInfo } from '@woodger/antd';
import dayjs, { type Dayjs } from 'dayjs';
const initialDate = dayjs('2026-10-15');
</script>
{#snippet cell(current: Dayjs | number | 'am' | 'pm', info: DatePickerCellRenderInfo)}
{@const firstDay = info.type === 'date' && dayjs.isDayjs(current) && current.date() === 1}
<span class="cell" class:month-start={firstDay}>
{@render info.originNode()}
</span>
{/snippet}
<div class="example">
<DatePicker
aria-label={("Calendar with marked dates")}
defaultPickerValue={initialDate}
cellRender={cell}
/>
<RangePicker
defaultPickerValue={initialDate}
placeholder={(["Start date in the marked calendar", "End date in the marked calendar"])}
cellRender={cell}
/>
</div>
<style>
.example {
display: grid;
gap: 16px;
}
.cell { display: contents; }
.month-start :global(button) {
border-radius: 50%;
box-shadow: inset 0 0 0 1px var(--ant-color-primary);
}
</style>
Panel heading
Choose a due date in the calendar or select “End of this month” below the panel heading.
<script lang="ts">
import { DatePicker } from '@woodger/antd';
import dayjs from 'dayjs';
</script>
{#snippet previous()}
<span class="month-arrow" aria-hidden="true">←</span>
{/snippet}
{#snippet next()}
<span class="month-arrow" aria-hidden="true">→</span>
{/snippet}
<DatePicker
aria-label={("Report due date")}
presets={([{ label: "End of this month", value: () => dayjs().endOf('month') }])}
prevIcon={previous}
nextIcon={next}
>
{#snippet panelRender(panel)}
<div class="report-panel">
<strong>{("Report due date")}</strong>
{@render panel()}
</div>
{/snippet}
</DatePicker>
<style>
.month-arrow { display: inline-block; }
.month-arrow:dir(rtl) { transform: scaleX(-1); }
.report-panel > strong {
display: block;
padding: 8px 12px;
border-bottom: 1px solid var(--ant-color-border-secondary);
}
</style>
Select a date with a slider
Use the slider to choose a day of the year. Sundays are unavailable.
<script lang="ts">
import { Button, DatePicker, Slider, type DatePickerPanelContext } from '@woodger/antd';
import dayjs from 'dayjs';
const firstDay = dayjs('2026-01-01');
const lastDay = firstDay.endOf('year').startOf('day');
const lastOffset = lastDay.diff(firstDay, 'day');
</script>
{#snippet datePanel(panel: DatePickerPanelContext)}
{@const date = panel.pickerValue.startOf('day')}
{@const dayOffset = date.diff(firstDay, 'day')}
<div class="date-panel">
<time datetime={date.format('YYYY-MM-DD')}>{date.format('YYYY-MM-DD')}</time>
<Slider
min={0}
max={lastOffset}
value={dayOffset}
ariaLabelForHandle={("Day of the year")}
ariaValueTextFormatterForHandle={offset => firstDay.add(offset, 'day').format('YYYY-MM-DD')}
onChange={offset => panel.onPickerValueChange(firstDay.add(offset, 'day'))}
tooltip={false}
/>
<Button
type="primary"
size="small"
disabled={panel.disabledDate(date, { type: 'date' })}
onclick={() => panel.onSelect(date)}
>{("Select date")}</Button>
</div>
{/snippet}
<DatePicker
aria-label={("Report date")}
defaultPickerValue={firstDay}
minDate={firstDay}
maxDate={lastDay}
disabledDate={date => date.day() === 0}
showNow={false}
components={{ date: datePanel }}
/>
<style>
.date-panel {
box-sizing: border-box;
display: grid;
gap: 8px;
width: min(280px, calc(100vw - 32px));
padding: 16px;
}
.date-panel time { font-variant-numeric: tabular-nums; }
</style>
Three sizes
large, medium and small for single field and range.
<script lang="ts">
import dayjs from 'dayjs';
import { DatePicker, RangePicker } from '@woodger/antd';
</script>
<style>
.example {
display: grid;
gap: 16px;
}
.row {
display: grid;
gap: 12px;
}
</style>
<div class="example">
{#each ['large', 'medium', 'small'] as const as size (size)}
<div class="row">
<DatePicker
aria-label={("DatePicker Size " + String((size)) + "")}
{size}
defaultValue={dayjs('2026-10-15')}
/>
<RangePicker {size} style="width:100%" placeholder={([
`Home ${size}`,
`End ${size}`
])} />
</div>
{/each}
</div>
Buddhist era: display
Day.js plugin changes the format of the value and title. Manual input is disabled: parsing the Buddhist year and the mask are not implemented in this example.
<script lang="ts">
import dayjs from 'dayjs';
import buddhistEra from 'dayjs/plugin/buddhistEra.js';
import { DatePicker } from '@woodger/antd';
dayjs.extend(buddhistEra);
</script>
<DatePicker
aria-label={("Date in the Buddhist era")}
defaultValue={dayjs('2026-10-15')}
inputReadOnly
format={date => date.format('DD/MM/BBBB')}
locale={{ lang: { yearFormat: 'BBBB', cellYearFormat: 'BBBB' } }}
/>
Date and time icons
The default suffix shows the validation icon. A custom suffix replaces it; local suffixIcon=true overrides provider settings.
<script lang="ts">
import {
ConfigProvider,
DatePicker,
Form,
FormItem,
RadioGroup,
RangePicker,
TimePicker,
TimeRangePicker,
createForm
} from '@woodger/antd';
const form = createForm({ initialValues: {} });
let suffix = $state('default');
const suffixIcon = $derived(
suffix === 'custom'
? customSuffix
: suffix === 'none'
? null
: undefined
);
</script>
{#snippet customSuffix()}<svg
width="16"
height="16"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
aria-hidden="true"
><circle
cx="10"
cy="10"
r="6"
/><path
d="m15 15 5 5"
/></svg>{/snippet}
<div class="settings">
<RadioGroup aria-label={("Date and time suffix")} bind:value={suffix}
options={([
{ value: 'default', label: "Default" }, { value: 'custom', label: "Own icon" }, {
value: 'none',
label: "Without icon"
}
])} />
</div>
<ConfigProvider datePicker={{ suffixIcon }} timePicker={{ suffixIcon }}>
<Form {form} aria-label={("Date and time icons")}>
<FormItem
label="DatePicker (suffixIcon=true)"
htmlFor="feedback-date"
validateStatus="success"
hasFeedback
>
<DatePicker
id="feedback-date"
aria-label="DatePicker feedback"
suffixIcon={true}
style="width:100%"
/>
</FormItem>
<FormItem label="RangePicker" htmlFor="feedback-range" validateStatus="warning" hasFeedback>
<RangePicker id="feedback-range" aria-label="RangePicker feedback" style="width:100%" />
</FormItem>
<FormItem label="TimePicker" htmlFor="feedback-time" validateStatus="error" hasFeedback>
<TimePicker id="feedback-time" aria-label="TimePicker feedback" style="width:100%" />
</FormItem>
<FormItem
label="TimeRangePicker"
htmlFor="feedback-time-range"
validateStatus="validating"
hasFeedback
>
<TimeRangePicker
id="feedback-time-range"
aria-label="TimeRangePicker feedback"
style="width:100%"
/>
</FormItem>
</Form>
</ConfigProvider>
<style>
.settings { margin-bottom: 24px; }
</style>
Test states
error and warning. The error is reflected in aria-invalid for the field.
<script lang="ts">
import { DatePicker, RangePicker } from '@woodger/antd';
</script>
<style>
.example {
display: grid;
gap: 16px;
}
</style>
<div class="example">
{#each ['error', 'warning'] as const as status (status)}
<DatePicker aria-label={("DatePicker Status " + String((status)) + "")} {status} />
<RangePicker {status} style="width:100%" placeholder={([
`Home ${status}`,
`End ${status}`
])} />
{/each}
</div>
Design options
outlined, filled, borderless and underlined for both components.
<script lang="ts">
import dayjs from 'dayjs';
import { DatePicker, RangePicker } from '@woodger/antd';
</script>
<style>
.example {
display: grid;
gap: 16px;
}
.row {
display: grid;
gap: 12px;
}
</style>
<div class="example">
{#each ['outlined', 'filled', 'borderless', 'underlined'] as const as variant (variant)}
<div class="row">
<DatePicker
aria-label={("DatePicker Option " + String((variant)) + "")}
{variant}
defaultValue={dayjs('2026-10-15')}
/>
<RangePicker {variant} style="width:100%" placeholder={([
`Home ${variant}`,
`End ${variant}`
])} />
</div>
{/each}
</div>
Panel position
Compare four popup positions. The range picker uses popupAlign for a 12-pixel gap. defaultPickerValue sets a separate initial month for each field.
<script lang="ts">
import dayjs from 'dayjs';
import {
ConfigProvider,
DatePicker,
RangePicker,
type DatePickerPopupAlign
} from '@woodger/antd';
const rangePlacements = {
bottomLeft: {
points: ['tl', 'bl'],
offset: [0, 4],
overflow: { adjustY: true, shiftX: true }
}
} satisfies Record<string, DatePickerPopupAlign>;
</script>
<style>
.example {
display: flex;
flex-wrap: wrap;
gap: 16px;
}
:global(.date-picker-example-popup) {
outline: 2px solid var(--ant-color-primary);
outline-offset: 2px;
}
:global(.range-example-header) { font-weight: 600; }
</style>
<ConfigProvider datePicker={{
classNames: { popup: { root: 'date-picker-example-popup' } },
styles: { prefix: 'color:var(--ant-color-primary)' },
allowClear: { clearIcon: '×' }
}}>
<div class="example">
{#each ['topLeft', 'topRight', 'bottomLeft', 'bottomRight'] as const as placement (placement)}
<DatePicker
aria-label={("Date position " + String((placement)) + "")}
{placement}
prefix="#"
placeholder={(placement)}
defaultPickerValue={dayjs('2026-10-15')}
style="width:150px"
/>
{/each}
<RangePicker
placeholder={(["Start with panel class", "End with panel class"])}
prefix="#"
placement="bottomLeft"
builtinPlacements={rangePlacements}
popupAlign={{ offset: [0, 12] }}
transitionName="ant-slide-up"
classNames={() => ({ popup: { header: 'range-example-header' } })}
defaultPickerValue={[dayjs('2026-10-15'), dayjs('2026-12-15')]}
style="width:300px"
/>
</div>
</ConfigProvider>
Localization
Nested ConfigProvider with ruRU and enUS from a public package. The calendar locale is separate from the date storage format.
<script lang="ts">
import dayjs from 'dayjs';
import { ConfigProvider, DatePicker, enUS, ruRU } from '@woodger/antd';
</script>
<style>
.example {
display: grid;
gap: 16px;
}
</style>
<div class="example">
<ConfigProvider locale={ruRU}>
<DatePicker
aria-label={("Russian calendar")}
defaultPickerValue={dayjs('2026-10-15')}
/>
</ConfigProvider>
<ConfigProvider locale={enUS}>
<DatePicker
aria-label={("English calendar")}
defaultPickerValue={dayjs('2026-10-15')}
/>
</ConfigProvider>
</div>
Date in Form
Mandatory field, send and reset. Form stores Dayjs directly; formatting is performed only on the example result.
<script lang="ts">
import dayjs, { type Dayjs } from 'dayjs';
import { Button, DatePicker, Form, FormItem, createForm } from '@woodger/antd';
const form = createForm<{ date: Dayjs | null }>({
initialValues: { date: null },
rules: ({ date: [{ required: true, message: "Select a meeting date." }] })
});
let result = $state('—');
</script>
<style>.actions {
display: flex;
flex-wrap: wrap;
gap: 8px;
} output {
display: block;
margin-top: 16px;
}</style>
<Form {form} onFinish={values => {
result = ("" + String((dayjs.isDayjs(values.date) ? 'Dayjs' : ("Not Dayjs"))) + ": " + String((values.date?.format('YYYY-MM-DD') ?? 'null')) + "");
}}>
<FormItem name="date" label={("Meeting date")}>
<DatePicker
aria-label={("Meeting date")}
value={form.values.date}
defaultPickerValue={dayjs('2026-10-15')}
onChange={date => form.setFieldValue('date', date)}
/>
</FormItem>
<div class="actions">
<Button htmlType="submit" type="primary">{("Save meeting")}</Button>
<Button
htmlType="reset"
onclick={() => { result = '—'; }}
>{("Reset meeting")}</Button>
</div>
</Form>
<output aria-label={("Date form result")}>{result}</output>
Event date
Saved example from the review with separate date and datetime.
<script lang="ts">
import dayjs, { type Dayjs } from 'dayjs';
import { DatePicker } from '@woodger/antd';
let date = $state<Dayjs | null>(dayjs('2026-10-29'));
let datetime = $state<Dayjs | null>(dayjs('2026-10-29T10:30:15.123'));
</script>
<style>
.date-field {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 8px;
}
output {
display: block;
margin-top: 16px;
}
</style>
<div style="
display: flex;
gap: 24px;
flex-wrap: wrap;
">
<div
class="date-field"
><label
for="showcase-date"
>{("Event date")}</label><DatePicker
id="showcase-date"
value={date}
onChange={next => { date = next; }}
/></div>
<div
class="date-field"
><label
for="showcase-datetime"
>{("Event date and time")}</label><DatePicker
id="showcase-datetime"
value={datetime}
showTime
onChange={next => { datetime = next; }}
/></div>
</div>
<output aria-label={("DatePicker value")}>{(date?.format('YYYY-MM-DD') ?? 'null')}</output>
<output aria-label={("Datetime DatePicker value")}>{(datetime?.format('YYYY-MM-DD HH:mm:ss.SSS') ?? 'null')}</output>
Event period in Form
Saved RangePicker example from the review: time, mandatory period, sending and reset.
<script lang="ts">
import dayjs from 'dayjs';
import {
RangePicker,
Form,
FormItem,
Button,
createForm,
type RangePickerValue
} from '@woodger/antd';
const form = createForm<{ period: RangePickerValue | null }>(
{
initialValues: { period: [dayjs('2026-10-10T09:00'), dayjs('2026-10-20T18:00')] },
rules: ({ period: [{ required: true, message: "Select period." }] })
}
);
let result = $state('');
</script>
<style>
output {
display: block;
margin-top: 16px;
}
</style>
<div style="
max-width: 640px;
min-width: 0;
">
<Form
{form}
onFinish={values => {
result = values.period?.map(date => date?.format('YYYY-MM-DD HH:mm:ss') ?? '—')
.join(' — ')
?? '';
}}
>
<FormItem name="period" label={("Event period")}>
<RangePicker
value={form.values.period}
showTime
style="width:100%"
onChange={next => form.setFieldValue('period', next)}
/>
</FormItem>
<div
style="
display: flex;
gap: 8px;
flex-wrap: wrap;
"
><Button
htmlType="submit"
type="primary"
>{("Save period")}</Button><Button
htmlType="reset"
>{("Reset period")}</Button></div>
</Form>
<output aria-label={("Saved period")}>{result}</output>
</div>
Local prefixCls specifies the full name of the field and panel, an empty string returns the common prefix with -picker. The OK button inherits a separate common Button prefix. Changing the prefix saves the open calendar, the input text and the not yet confirmed time. Changing format reformats the value. CSS variables are included separately; both models store Dayjs.
CSS date prefixes
General and local prefixCls fields and panels, RTL and separate namespace CSS variables. Changing the prefix preserves the draft input and the unconfirmed time.
<script lang="ts">
import dayjs, { type Dayjs } from 'dayjs';
import {
Checkbox,
ConfigProvider,
DatePicker,
RangePicker,
type RangePickerValue
} from '@woodger/antd';
let custom = $state(true);
let local = $state(true);
let rtl = $state(false);
let withVariables = $state(false);
let alternateFormat = $state(false);
let date = $state.raw<Dayjs | null>(dayjs('2026-10-15T09:30'));
let range = $state.raw<RangePickerValue | null>([
dayjs('2026-10-15T09:30'), dayjs('2026-10-18T18:00')
]);
let dateChanges = $state(0);
let rangeChanges = $state(0);
const prefix = $derived(custom ? 'suite' : 'ant');
const localPrefix = $derived(local ? 'project-picker' : '');
const format = $derived(
alternateFormat
? 'DD/MM/YYYY HH:mm'
: 'YYYY-MM-DD HH:mm'
);
</script>
<style>
.example,
section {
display: grid;
grid-template-columns: minmax(0, 1fr);
gap: 16px;
min-width: 0;
}
.controls {
display: flex;
flex-wrap: wrap;
gap: 12px;
}
p { margin: 0; }
output { overflow-wrap: anywhere; }
</style>
<div class="example">
<div class="controls">
<Checkbox bind:checked={custom}>{("Common prefix DatePicker suite")}</Checkbox>
<Checkbox bind:checked={local}>{("Local DatePicker Prefix")}</Checkbox>
<Checkbox bind:checked={rtl}>{("RTL DatePicker with prefix")}</Checkbox>
<Checkbox bind:checked={withVariables}>CSS variables DatePicker</Checkbox>
<Checkbox bind:checked={alternateFormat}>{("Other DatePicker format")}</Checkbox>
</div>
<ConfigProvider prefixCls={prefix} direction={rtl ? 'rtl' : 'ltr'}
theme={withVariables ? { cssVar: { prefix: 'dates-theme' } } : undefined}>
<section aria-label={("Single date with prefix")}>
<DatePicker
prefixCls={localPrefix}
class="prefix-date-main"
id="prefix-date"
aria-label={("Date with CSS prefix")}
value={date}
{format}
showNow={false}
showTime={{ format: 'HH:mm', minuteStep: 5 }}
onChange={next => {
date = next;
dateChanges++;
}}
/>
<output aria-label={("Date with prefix")}>{(date?.format('YYYY-MM-DD HH:mm') ?? 'null')}</output>
<output
aria-label={("Date changes with prefix")}
>{("Changes: ")}{dateChanges}</output>
</section>
<section aria-label={("Date range with prefix")}>
<RangePicker prefixCls={localPrefix} class="prefix-date-range" style="width:100%"
id={{ start: 'prefix-date-start', end: 'prefix-date-end' }}
value={range} {format} showNow={false}
placeholder={(["Start of dates with prefix", "End of dates with prefix"])}
showTime={{ format: 'HH:mm', minuteStep: 5 }}
onChange={next => {
range = next;
rangeChanges++;
}} />
<output aria-label={("Date range with CSS prefix")}>
{(range?.map(item => item?.format('YYYY-MM-DD HH:mm') ?? '—').join(' — ') ?? 'null')}
</output>
<output aria-label={("Date range changes with prefix")}>{("Changes: ")}{rangeChanges}</output>
</section>
</ConfigProvider>
<output aria-label={("DatePicker CSS prefix")}>Picker: {(localPrefix
|| prefix + '-picker')}</output>
<p>
{("Local prefixCls specifies the full name of the field and panel, an empty string returns the common prefix with -picker. The OK button inherits a separate common Button prefix. Changing the prefix saves the open calendar, the input text and the not yet confirmed time. Changing format reformats the value. CSS variables are included separately; both models store Dayjs.")}
</p>
</div>
Coverage Examples
Matched 25 themes of ant.design 6.7 live page. The package ports the Ant Design 6.6.8 API in parts: below, the available scenarios and the features that have not yet been ported are distinguished.
| Theme | Condition | Application in Svelte |
|---|---|---|
| Basic | Implemented | Base date.Choose a day, week, month, quarter or year. The calendar can also show week numbers. |
| Range Picker | Implemented | Date range.Ranges of days, weeks, months, quarters and years. Day ranges can include times. |
| Multiple | Implemented | Multiple dates.Pick several dates in one calendar. Each selected date appears as a tag. |
| Need Confirm | Implemented | Confirm selection.Draft and confirmation of meaning. |
| Switchable picker | Partially | Day, week, month, quarter and year.Switch between all five calendar modes here. The TimePicker page covers time-only selection. |
| Date Format | Implemented | Formats and erroneous input.String, output function and array of valid strings. |
| Choose Time | Implemented | Date and time.Date and datetime range with time settings. |
| Mask Format | Implemented | Date input mask.Use the left and right arrows to select a part of the date. |
| Limit Date Range | Implemented | Limits of available dates.Selection and navigation boundaries. |
| Disabled | Implemented | Inaccessible fields.Entire field or separate border. |
| Disabled Date & Time | Implemented | Date and time restrictions.Date and time restrictions. |
| Allow Empty | Implemented | Optional border.Optional range limit. |
| Select range dates | Implemented | No more than seven days.Dynamic constraint with info.from. |
| Preset Ranges | Implemented | Finished periods.Value or callback of RangePicker.presets. |
| Extra Footer | Implemented | Explanation in the panel.The calendar footer adapts to the current panel mode. |
| Three Sizes | Implemented | Three sizes.Single field and range sizes. |
| Customized Cell Rendering | Implemented | First day of the month.The example highlights the first of each month and keeps the native date buttons. |
| Customize Panel | Implemented | Select a date with a slider.components.date replaces the calendar grid with a slider and a selection button. |
| External use panel | Not supported | The calendar panel is not exported separately. |
| Buddhist Era | Partially | Buddhist era: display.Value and header format; manual input is disabled. |
| Status | Implemented | Test states.Error and warning. |
| Variants | Implemented | Design options.Four designs. |
| Custom semantic dom styling | Implemented | Panel position.A slot map or a function of the current props supplies classes and styles for the field and panel. |
| Placement | Implemented | Panel position.Four positions with edge correction. |
| Prefix and Suffix | Implemented | Panel position.prefix adds content before the date and suffixIcon changes the trailing icon. |
API
The standard DatePicker returns Dayjs or an array of Dayjs values. Clearing returns null.
| Property | Description | Type | Default |
|---|---|---|---|
multiple | Select several dates or periods without a time of day. | boolean | false |
maxTagCount | Limits the number of visible tags in multiple selection. | number | "responsive" | — |
mode | Controls the visible panel. onPanelChange receives the next requested mode. | DatePickerMode | — |
suffixIcon | undefined/true display the calendar and Form feedback. A snippet or content replaces the suffix; null/false/an empty string hide it. A local value overrides the provider. | InputContent | ConfigProvider.datePicker.suffixIcon |
prefixCls | Full local field and panel name. Empty string/undefined select provider prefix with -picker; a separate OK button retains the common Button prefix. | string | General prefix + -picker |
picker | Selection unit for a single value or a range: date, week, month, quarter or year. | DatePickerPicker | date |
showWeek | Shows week numbers beside the dates. Selecting a number picks the first day in that row. | boolean | picker === 'week' |
value | Controlled date via onChange; without bind:value and automatic UTC serialization. | Dayjs | readonly Dayjs[] | null | undefined |
components | Replaces the input or the contents of the panel for a given mode. | DatePickerComponents | undefined |
autoFocus | Focuses the editor when it appears. A range focuses the first enabled field. | boolean | false |
tabIndex | Sets the tab order for the field. | number | undefined |
autoComplete | Controls browser autocomplete for the field. | HTMLInputAttributes["autocomplete"] | off |
defaultValue | Starting local date. | Dayjs | readonly Dayjs[] | null | undefined |
format | The first format controls the display. An object with type=mask enables segmented input. | DatePickerFormat | DatePickerFormat[] | DatePickerFormatConfig | From locale/showTime |
showTime | Adds time when picking a day. defaultOpenValue sets the initial time and disabledTime restricts the available times. | boolean | DatePickerTimeConfig | false |
needConfirm | Publication after OK; onCalendarChange reports the draft. | boolean | picker === 'date' && Boolean(showTime) |
disabledDate | Excludes dates. | (date, { type }) => boolean | undefined |
disabledTime | Limits the hours, minutes, seconds and milliseconds of showTime. | (date) => DatePickerDisabledTime | undefined |
minDate | Lower limit for selection and navigation. | Dayjs | undefined |
maxDate | Upper limit for selection and navigation. | Dayjs | undefined |
open | Controlled opening. defaultOpen sets the initial one, onOpenChange reports the request. | boolean | Local |
defaultPickerValue | Start date of the panel each time it is opened, separate from value. | Dayjs | Current/selected date |
pickerValue | Controllable panel; respond to onPickerValueChange for navigation. | Dayjs | Local |
onChange | Single selection returns a date and a string. Multiple selection returns two arrays, with both arguments set to null when cleared. | DatePickerProps["onChange"] | DatePickerMultipleProps["onChange"] | — |
onCalendarChange | Draft with source=date or time. | (value, text, { source }) => void | — |
onFocus | Focus event. | DatePickerProps["onFocus"] | — |
onBlur | Blur event. | DatePickerProps["onBlur"] | — |
onKeyDown | Keyboard event from the editor. | DatePickerProps["onKeyDown"] | — |
onOk | OK sends the draft before onChange and panel closure. | DatePickerProps["onOk"] | DatePickerMultipleProps["onOk"] | — |
onPickerValueChange | The panel date and why it changed: panel for navigation or selection, reset on opening. | (value: Dayjs, info) => void | — |
onPanelChange | Reports the date and the current panel mode, including decade navigation. | (value, mode: DatePickerMode) => void | — |
allowClear | Shows the clear button. Pass an object with clearIcon to customize its icon. | DatePickerAllowClear | true |
inputReadOnly | Blocks typing in a plain field. With a mask, the keyboard can still change the value. | boolean | false |
preserveInvalidOnBlur | Keeps invalid text and aria-invalid after blur while preserving the accepted date. | boolean | false |
showNow | “Today” button without showTime or “Now” when selecting a time. | boolean | true |
classNames | A slot map or a function of the current props supplies classes and styles for the field and panel. | DatePickerSemantic | undefined |
locale | Local lang complements the general locale. | DatePickerLocale | From ConfigProvider |
presets | Date shortcuts. Each value is a Dayjs instance or a function returning one. | readonly DatePickerPreset[] | undefined |
previewValue | Hover over a preset to preview its date in the input before selection. | false | 'hover' | hover |
cellRender | Customizes a calendar or time cell. Render info.originNode to keep its standard button. | Snippet<[Dayjs | number | 'am' | 'pm', DatePickerCellRenderInfo]> | undefined |
panelRender | Wraps the entire panel, including presets and the footer. | Snippet<[Snippet]> | undefined |
renderExtraFooter | Renders content below the calendar and receives the current panel mode. | Snippet<[DatePickerMode]> | undefined |
size | large, medium and small. | ComponentSize | From context |
variant | Local variant → closest Form.variant → ConfigProvider.datePicker.variant → general ConfigProvider.variant → outlined. | outlined | filled | borderless | underlined | From context / outlined |
status | Check status. | error | warning | From FormItem |
placement | Starting position taking into account LTR/RTL. | topLeft | topRight | bottomLeft | bottomRight | bottomLeft / bottomRight |
popupAlign | Overrides anchor points, offsets and overflow settings for the selected placement. | DatePickerPopupAlign | — |
builtinPlacements | Replaces the placement map for the panel. | Readonly<Record<string, DatePickerPopupAlign>> | Built-in map |
transitionName | Name of the popup CSS animation. | string | Component animation |
getPopupContainer | The local container takes precedence. | (trigger) => HTMLElement | ShadowRoot | From ConfigProvider |
RangePicker API
RangePicker is exported separately. It inherits common date parameters, changing value types, times and callbacks. Don't replace it with two independent DatePickers: boundaries use a common range model.
| Property | Description | Type | Default |
|---|---|---|---|
mode | Controls the start and end panel modes. onPanelChange returns the updated pair. | Readonly<RangePickerMode> | — |
components | Replaces the input or the contents of the panel for a given mode. | DatePickerComponents | undefined |
prefixCls | Local prefix of both fields and the common range panel. Does not rename individual OK button or theme namespace. | string | General prefix + -picker |
classNames | A slot map or a function of the current props supplies classes and styles for the field and panel. | DatePickerSemantic | undefined |
showNow | Quickly select the current date or time for the active boundary. | boolean | false |
popupAlign | Overrides anchor points, offsets and overflow settings for the selected placement. | DatePickerPopupAlign | — |
builtinPlacements | Replaces the placement map for the panel. | Readonly<Record<string, DatePickerPopupAlign>> | Built-in map |
transitionName | Name of the popup CSS animation. | string | Component animation |
defaultPickerValue | Initial panel dates for both fields. A single value sets the start panel date. | Dayjs | [Dayjs, Dayjs] | null | — |
pickerValue | Controlled panel dates. Pass a pair for the start and end, and update it via onPickerValueChange. | Dayjs | [Dayjs, Dayjs] | null | Local |
value | Dayjs/null/undefined pair at the input. Callback returns RangePickerValue or null. | RangePickerInputValue | null | undefined |
onChange | Full clear returns null in both arguments. | (value, texts: [string, string] | null) => void | — |
onCalendarChange | Intermediate start/end selection. | (value, texts, { range }) => void | — |
onPickerValueChange | The two panel dates, active boundary, reason for the change and both panel modes. | (dates: [Dayjs, Dayjs], info) => void | — |
onPanelChange | Reports the dates and modes of both panels when the calendar view changes. | (value: RangePickerValue, modes) => void | — |
allowEmpty | Allows empty border. | boolean | [boolean, boolean] | false |
disabled | Disables both or selected borders. | boolean | [boolean, boolean] | From context |
order | Automatically arranges borders. | boolean | true |
presets | label - text or snippet; value - pair or function. | readonly RangePickerPreset[] | undefined |
previewValue | Preliminary hover range. | false | 'hover' | hover |
disabledDate | From allows you to limit the second date relative to the first. | (date, { type, from? }) => boolean | undefined |
disabledTime | Time constraints with boundary context. | (date, start | end, { from? }) => DatePickerDisabledTime | undefined |
showTime | defaultOpenValue contains two initial times. | boolean | RangePickerTimeConfig | false |
id | For individual label, set different id. | string | { start?: string; end?: string } | undefined |
placeholder | Various field hints. | [string, string] | From locale |
autoFocus | Focuses the editor when it appears. A range focuses the first enabled field. | boolean | false |
tabIndex | Sets the tab order for the field. | number | undefined |
autoComplete | Controls browser autocomplete for the field. | HTMLInputAttributes["autocomplete"] | off |
separator | Separator, also ConfigProvider.rangePicker.separator. | string | Snippet | Arrow |
Both pickers share picker, cellRender and panelRender. In a range, info.range identifies the boundary being edited, including in cells on either panel. For time selection, defaultOpenValue takes a pair of Dayjs values.
ConfigProvider.datePicker sets variant and suffixIcon. For ranges, ConfigProvider.rangePicker accepts class, style, variant and separator. The local variant takes priority, followed by Form, the component settings and the provider-wide variant.
Methods
focus() and blur() are available through bind:this. Focus accepts preventScroll and cursor=start/end/all. For RangePicker index=0/1 selects a field; bind:startInput and bind:endInput give native elements. For both components, bind:nativeElement returns the root div.
<script lang="ts">
import dayjs from 'dayjs';
import { Button, DatePicker, RangePicker } from '@woodger/antd';
let single = $state<ReturnType<typeof DatePicker>>();
let range = $state<ReturnType<typeof RangePicker>>();
</script>
<style>.example {
display: grid;
gap: 16px;
} .actions {
display: flex;
flex-wrap: wrap;
gap: 8px;
}</style>
<div class="example">
<DatePicker
bind:this={single}
aria-label={("DatePicker Methods")}
defaultValue={dayjs('2026-10-15')}
/>
<RangePicker bind:this={range} style="width:100%"
defaultValue={[dayjs('2026-10-15'), dayjs('2026-10-20')]}
placeholder={(["Methods start", "Methods end"])} />
<div class="actions">
<Button
onclick={() => single?.focus({ cursor: 'all' })}
>{("Focus DatePicker")}</Button>
<Button onclick={() => single?.blur()}>{("Remove Focus DatePicker")}</Button>
<Button onclick={() => range?.focus({ index: 1, cursor: 'all' })}>
{("Focus End RangePicker")}
</Button>
<Button onclick={() => range?.blur()}>{("Remove focus RangePicker")}</Button>
</div>
</div>
DOM and keyboard
Native input elements have the role of combobox, aria-expanded and communication with the dialog panel via aria-controls. RangePicker has two fields: link separate label via id.start/id.end and give clear names to both fields.
Arrows move the selection in the open calendar, Enter confirms a valid date, Escape closes the panel. When needConfirm, the final value is published by the OK button. Unavailable dates and times are blocked regardless of the input method.
DatePicker and RangePicker available classNames.popup.root for panel class; position example shows shared styling through ConfigProvider.datePicker and local panel classes.
Registration tokens
DatePicker and RangePicker read theme.components.DatePicker. Tokens prefixed with multiple style the selected tags.
| Token | Purpose |
|---|---|
activeBg | Active field background. |
activeBorderColor | Active frame. |
activeShadow | Focus shadow. |
addonBg | Background of the additional area. |
cellActiveWithRangeBg | Selected range. |
cellBgDisabled | Unavailable day background. |
cellHeight | Cell height. |
cellHoverBg | Targeting a cell. |
cellHoverWithRangeBg | Preliminary range. |
cellRangeBorderColor | Range frame. |
cellWidth | Cell width. |
errorActiveShadow | Error shadow. |
hoverBg | Field background when hovering. |
hoverBorderColor | Hover frame. |
inputFontSize | Middle field text. |
inputFontSizeLG | Large field text. |
inputFontSizeSM | Small field text. |
multipleItemBg | Multiple tag background. |
multipleItemBorderColor | Multiple tag frame. |
multipleItemBorderColorDisabled | Inaccessible multiple tag frame. |
multipleItemColorDisabled | Inaccessible multiple tag text. |
multipleItemHeight | Height of multiple tag. |
multipleItemHeightLG | Large multiple tag. |
multipleItemHeightSM | Small multiple tag. |
multipleSelectorBgDisabled | Inaccessible multiple-selector. |
paddingBlock | Vertical offset. |
paddingBlockLG | Large margin indent. |
paddingBlockSM | Small margin indent. |
paddingInline | Horizontal offset. |
paddingInlineLG | Large margin indent. |
paddingInlineSM | Small margin indent. |
presetsMaxWidth | Maximum width of presets. |
presetsWidth | Width presets. |
textHeight | Text height. |
timeCellHeight | Time variant height. |
timeColumnHeight | Height of the time column. |
timeColumnWidth | Time column width. |
warningActiveShadow | Shadow warning. |
withoutTimeCellHeight | Day altitude without time. |
zIndexPopup | Layer popup. |
Common tokens of the current topic
Names are checked against the common table ant.design; the current values are read via theme.useToken().
| Token | Meaning |
|---|---|
colorBgContainer | #ffffff |
colorBgContainerDisabled | rgba(0,0,0,0.04) |
colorBgElevated | #ffffff |
colorBorder | #d9d9d9 |
colorBorderDisabled | #d9d9d9 |
colorError | #ff4d4f |
colorErrorAffix | #ff4d4f |
colorErrorBg | #fff2f0 |
colorErrorBgHover | #fff1f0 |
colorErrorBorderHover | #ffa39e |
colorErrorText | #ff4d4f |
colorFillSecondary | rgba(0,0,0,0.06) |
colorFillTertiary | rgba(0,0,0,0.04) |
colorIcon | rgba(0,0,0,0.45) |
colorIconHover | rgba(0,0,0,0.88) |
colorLink | #1677ff |
colorLinkActive | #0958d9 |
colorLinkHover | #69b1ff |
colorPrimary | #2f54eb |
colorPrimaryBorder | #adc6ff |
colorSplit | rgba(5,5,5,0.06) |
colorText | rgba(0,0,0,0.88) |
colorTextDisabled | rgba(0,0,0,0.25) |
colorTextHeading | rgba(0,0,0,0.88) |
colorTextLightSolid | #fff |
colorTextPlaceholder | rgba(0,0,0,0.25) |
colorTextQuaternary | rgba(0,0,0,0.25) |
colorTextTertiary | rgba(0,0,0,0.45) |
colorWarning | #faad14 |
colorWarningAffix | #faad14 |
colorWarningBg | #fffbe6 |
colorWarningBgHover | #fff1b8 |
colorWarningBorderHover | #ffd666 |
colorWarningText | #faad14 |
borderRadius | 6 |
borderRadiusLG | 8 |
borderRadiusSM | 4 |
borderRadiusXS | 2 |
boxShadowSecondary |
0 6px 16px 0 rgba(0,0,0,0.08),
0 3px 6px -4px rgba(0,0,0,0.12),
0 9px 28px 8px rgba(0,0,0,0.05)
|
controlHeight | 32 |
controlHeightLG | 40 |
controlHeightSM | 24 |
controlItemBgActive | #f0f5ff |
fontFamily | -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial,
'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol',
'Noto Color Emoji' |
fontSize | 14 |
fontSizeLG | 16 |
fontSizeSM | 12 |
fontWeightStrong | 600 |
lineHeight | 1.5714285714285714 |
lineHeightLG | 1.5 |
lineType | solid |
lineWidth | 1 |
lineWidthBold | 2 |
linkDecoration | none |
linkFocusDecoration | none |
linkHoverDecoration | none |
marginXS | 8 |
marginXXS | 4 |
motionDurationMid | 0.2s |
motionDurationSlow | 0.3s |
motionEaseInOutCirc | cubic-bezier(0.78, 0.14, 0.15, 0.86) |
motionEaseInQuint | cubic-bezier(0.755, 0.05, 0.855, 0.06) |
motionEaseOutCirc | cubic-bezier(0.08, 0.82, 0.17, 1) |
motionEaseOutQuint | cubic-bezier(0.23, 1, 0.32, 1) |
padding | 16 |
paddingSM | 12 |
paddingXS | 8 |
paddingXXS | 4 |
sizePopupArrow | 16 |
FAQ
How do I enter the last week of a year?
In the Russian locale, enter 2023-52 to select the week of December 25–31, 2023. Week 52 is written as 2023-52周 in Chinese and 2023-52nd in US English. If the year has no such week, as with 2021-53 in the Russian locale, the field marks the entry as invalid and keeps the previous value.
Why do the days open again after selecting a year?
To select a year as the value, set picker="year". The mode prop chooses the visible panel. In the controlled panels example, onPanelChange updates one field mode or the pair of range modes.
How to set the language and the first day of the week?
Match the locale of the component or ConfigProvider with the loaded Day.js locale. The first day of the week is determined by the settings of that locale; global dayjs.locale is not enough to translate the interface.
How to limit the second end relative to the first?
Use info.from in disabledDate. For time, partial=start/end and info.from are additionally available in disabledTime.
When to serialize a date?
When preparing an application request. Form and local state are stored by Dayjs; formatting for display does not select UTC, ISO or storage time zone.
Is it possible to edit the Buddhist year like a regular year?
Example from the Buddhist era changes the display of value and title via the Day.js plugin. Input is disabled: the backparser and Buddhist year mask are not implemented, and the year selection retains Gregorian values.