Ant Design Svelte

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

null

Base date

Calendar selection or manual entry. value is stored as Dayjs | null; onChange accepts a new object.

2026-10-05, 2026-10-12

Multiple dates

Pick several dates in one calendar. Each selected date appears as a tag.

year
month / year

Controlled panels

The field requests a transition through onPanelChange. A range keeps a separate mode for each endpoint.

null

Date range

Choose the start and end in one calendar. The fields show the two ends of the range.

2026-10-15T00:00:00.000Z
— – —

Date and range with JavaScript Date

Choose a delivery date or window in UTC. The model stores Date objects.

Day, week, month, quarter and year

Switch the unit for both the single picker and the range picker.

Draft: —; meaning: null —

Confirm selection

Choose a date and click OK to see the order of confirmation callbacks.

2026-10-15

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.

—

Date input mask

Enter the year, month and day. For a range, also enter the time at each endpoint.

No events
Delivery window

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.

Focus when the field appears

Click “Set date” to show and focus the field.

null
null

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.

Limits of available dates

minDate/maxDate limits the selection from October 10 to October 20, 2026 and panel transitions.

Inaccessible fields

A single field can be disabled entirely, while a RangePicker can have only one border via the disabled array.

Date and time restrictions

Weekends are excluded via disabledDate, hours outside of working hours – via disabledTime. The time limit works in conjunction with showTime.

2026-10-15 — no deadline

Optional border

allowEmpty=[false, true] allows the absence of an end while preserving the required beginning.

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.

null

Finished periods

Static range and function that calculates dates at the time of selection. Guidance shows the preliminary range without changing the model.

First day of the month

A circle marks the first of each month. Select dates with the mouse or keyboard.

Panel heading

Choose a due date in the calendar or select “End of this month” below the panel heading.

Select a date with a slider

Use the slider to choose a day of the year. Sundays are unavailable.

Three sizes

large, medium and small for single field and range.

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.

Date and time icons

The default suffix shows the validation icon. A custom suffix replaces it; local suffixIcon=true overrides provider settings.

Test states

error and warning. The error is reflected in aria-invalid for the field.

Design options

outlined, filled, borderless and underlined for both components.

#
#
#
#
#

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.

Localization

Nested ConfigProvider with ruRU and enUS from a public package. The calendar locale is separate from the date storage format.

—

Date in Form

Mandatory field, send and reset. Form stores Dayjs directly; formatting is performed only on the example result.

2026-10-29 2026-10-29 10:30:15.123

Event date

Saved example from the review with separate date and datetime.

Event period in Form

Saved RangePicker example from the review: time, mandatory period, sending and reset.

2026-10-15 09:30 Changes: 0
2026-10-15 09:30 — 2026-10-18 18:00 Changes: 0
Picker: project-picker

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.

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.

Topics of official DatePicker and RangePicker examples
ThemeConditionApplication in Svelte
BasicImplementedBase date.Choose a day, week, month, quarter or year. The calendar can also show week numbers.
Range PickerImplementedDate range.Ranges of days, weeks, months, quarters and years. Day ranges can include times.
MultipleImplementedMultiple dates.Pick several dates in one calendar. Each selected date appears as a tag.
Need ConfirmImplementedConfirm selection.Draft and confirmation of meaning.
Switchable pickerPartiallyDay, week, month, quarter and year.Switch between all five calendar modes here. The TimePicker page covers time-only selection.
Date FormatImplementedFormats and erroneous input.String, output function and array of valid strings.
Choose TimeImplementedDate and time.Date and datetime range with time settings.
Mask FormatImplementedDate input mask.Use the left and right arrows to select a part of the date.
Limit Date RangeImplementedLimits of available dates.Selection and navigation boundaries.
DisabledImplementedInaccessible fields.Entire field or separate border.
Disabled Date & TimeImplementedDate and time restrictions.Date and time restrictions.
Allow EmptyImplementedOptional border.Optional range limit.
Select range datesImplementedNo more than seven days.Dynamic constraint with info.from.
Preset RangesImplementedFinished periods.Value or callback of RangePicker.presets.
Extra FooterImplementedExplanation in the panel.The calendar footer adapts to the current panel mode.
Three SizesImplementedThree sizes.Single field and range sizes.
Customized Cell RenderingImplementedFirst day of the month.The example highlights the first of each month and keeps the native date buttons.
Customize PanelImplementedSelect a date with a slider.components.date replaces the calendar grid with a slider and a selection button.
External use panelNot supportedThe calendar panel is not exported separately.
Buddhist EraPartiallyBuddhist era: display.Value and header format; manual input is disabled.
StatusImplementedTest states.Error and warning.
VariantsImplementedDesign options.Four designs.
Custom semantic dom stylingImplementedPanel position.A slot map or a function of the current props supplies classes and styles for the field and panel.
PlacementImplementedPanel position.Four positions with edge correction.
Prefix and SuffixImplementedPanel 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.

Main parameters DatePicker
PropertyDescriptionTypeDefault
multipleSelect several dates or periods without a time of day.booleanfalse
maxTagCountLimits the number of visible tags in multiple selection.number | "responsive"—
modeControls the visible panel. onPanelChange receives the next requested mode.DatePickerMode—
suffixIconundefined/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.InputContentConfigProvider.datePicker.suffixIcon
prefixClsFull local field and panel name. Empty string/undefined select provider prefix with -picker; a separate OK button retains the common Button prefix.stringGeneral prefix + -picker
pickerSelection unit for a single value or a range: date, week, month, quarter or year.DatePickerPickerdate
showWeekShows week numbers beside the dates. Selecting a number picks the first day in that row.booleanpicker === 'week'
valueControlled date via onChange; without bind:value and automatic UTC serialization.Dayjs | readonly Dayjs[] | nullundefined
componentsReplaces the input or the contents of the panel for a given mode.DatePickerComponentsundefined
autoFocusFocuses the editor when it appears. A range focuses the first enabled field.booleanfalse
tabIndexSets the tab order for the field.numberundefined
autoCompleteControls browser autocomplete for the field.HTMLInputAttributes["autocomplete"]off
defaultValueStarting local date.Dayjs | readonly Dayjs[] | nullundefined
formatThe first format controls the display. An object with type=mask enables segmented input.DatePickerFormat | DatePickerFormat[] | DatePickerFormatConfigFrom locale/showTime
showTimeAdds time when picking a day. defaultOpenValue sets the initial time and disabledTime restricts the available times.boolean | DatePickerTimeConfigfalse
needConfirmPublication after OK; onCalendarChange reports the draft.booleanpicker === 'date' && Boolean(showTime)
disabledDateExcludes dates.(date, { type }) => booleanundefined
disabledTimeLimits the hours, minutes, seconds and milliseconds of showTime.(date) => DatePickerDisabledTimeundefined
minDateLower limit for selection and navigation.Dayjsundefined
maxDateUpper limit for selection and navigation.Dayjsundefined
openControlled opening. defaultOpen sets the initial one, onOpenChange reports the request.booleanLocal
defaultPickerValueStart date of the panel each time it is opened, separate from value.DayjsCurrent/selected date
pickerValueControllable panel; respond to onPickerValueChange for navigation.DayjsLocal
onChangeSingle selection returns a date and a string. Multiple selection returns two arrays, with both arguments set to null when cleared.DatePickerProps["onChange"] | DatePickerMultipleProps["onChange"]—
onCalendarChangeDraft with source=date or time.(value, text, { source }) => void—
onFocusFocus event.DatePickerProps["onFocus"]—
onBlurBlur event.DatePickerProps["onBlur"]—
onKeyDownKeyboard event from the editor.DatePickerProps["onKeyDown"]—
onOkOK sends the draft before onChange and panel closure.DatePickerProps["onOk"] | DatePickerMultipleProps["onOk"]—
onPickerValueChangeThe panel date and why it changed: panel for navigation or selection, reset on opening.(value: Dayjs, info) => void—
onPanelChangeReports the date and the current panel mode, including decade navigation.(value, mode: DatePickerMode) => void—
allowClearShows the clear button. Pass an object with clearIcon to customize its icon.DatePickerAllowCleartrue
inputReadOnlyBlocks typing in a plain field. With a mask, the keyboard can still change the value.booleanfalse
preserveInvalidOnBlurKeeps invalid text and aria-invalid after blur while preserving the accepted date.booleanfalse
showNow“Today” button without showTime or “Now” when selecting a time.booleantrue
classNamesA slot map or a function of the current props supplies classes and styles for the field and panel.DatePickerSemanticundefined
localeLocal lang complements the general locale.DatePickerLocaleFrom ConfigProvider
presetsDate shortcuts. Each value is a Dayjs instance or a function returning one.readonly DatePickerPreset[]undefined
previewValueHover over a preset to preview its date in the input before selection.false | 'hover'hover
cellRenderCustomizes a calendar or time cell. Render info.originNode to keep its standard button.Snippet<[Dayjs | number | 'am' | 'pm', DatePickerCellRenderInfo]>undefined
panelRenderWraps the entire panel, including presets and the footer.Snippet<[Snippet]>undefined
renderExtraFooterRenders content below the calendar and receives the current panel mode.Snippet<[DatePickerMode]>undefined
sizelarge, medium and small.ComponentSizeFrom context
variantLocal variant → closest Form.variant → ConfigProvider.datePicker.variant → general ConfigProvider.variant → outlined.outlined | filled | borderless | underlinedFrom context / outlined
statusCheck status.error | warningFrom FormItem
placementStarting position taking into account LTR/RTL.topLeft | topRight | bottomLeft | bottomRightbottomLeft / bottomRight
popupAlignOverrides anchor points, offsets and overflow settings for the selected placement.DatePickerPopupAlign—
builtinPlacementsReplaces the placement map for the panel.Readonly<Record<string, DatePickerPopupAlign>>Built-in map
transitionNameName of the popup CSS animation.stringComponent animation
getPopupContainerThe local container takes precedence.(trigger) => HTMLElement | ShadowRootFrom 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.

Main parameters RangePicker
PropertyDescriptionTypeDefault
modeControls the start and end panel modes. onPanelChange returns the updated pair.Readonly<RangePickerMode>—
componentsReplaces the input or the contents of the panel for a given mode.DatePickerComponentsundefined
prefixClsLocal prefix of both fields and the common range panel. Does not rename individual OK button or theme namespace.stringGeneral prefix + -picker
classNamesA slot map or a function of the current props supplies classes and styles for the field and panel.DatePickerSemanticundefined
showNowQuickly select the current date or time for the active boundary.booleanfalse
popupAlignOverrides anchor points, offsets and overflow settings for the selected placement.DatePickerPopupAlign—
builtinPlacementsReplaces the placement map for the panel.Readonly<Record<string, DatePickerPopupAlign>>Built-in map
transitionNameName of the popup CSS animation.stringComponent animation
defaultPickerValueInitial panel dates for both fields. A single value sets the start panel date.Dayjs | [Dayjs, Dayjs] | null—
pickerValueControlled panel dates. Pass a pair for the start and end, and update it via onPickerValueChange.Dayjs | [Dayjs, Dayjs] | nullLocal
valueDayjs/null/undefined pair at the input. Callback returns RangePickerValue or null.RangePickerInputValue | nullundefined
onChangeFull clear returns null in both arguments.(value, texts: [string, string] | null) => void—
onCalendarChangeIntermediate start/end selection.(value, texts, { range }) => void—
onPickerValueChangeThe two panel dates, active boundary, reason for the change and both panel modes.(dates: [Dayjs, Dayjs], info) => void—
onPanelChangeReports the dates and modes of both panels when the calendar view changes.(value: RangePickerValue, modes) => void—
allowEmptyAllows empty border.boolean | [boolean, boolean]false
disabledDisables both or selected borders.boolean | [boolean, boolean]From context
orderAutomatically arranges borders.booleantrue
presetslabel - text or snippet; value - pair or function.readonly RangePickerPreset[]undefined
previewValuePreliminary hover range.false | 'hover'hover
disabledDateFrom allows you to limit the second date relative to the first.(date, { type, from? }) => booleanundefined
disabledTimeTime constraints with boundary context.(date, start | end, { from? }) => DatePickerDisabledTimeundefined
showTimedefaultOpenValue contains two initial times.boolean | RangePickerTimeConfigfalse
idFor individual label, set different id.string | { start?: string; end?: string }undefined
placeholderVarious field hints.[string, string]From locale
autoFocusFocuses the editor when it appears. A range focuses the first enabled field.booleanfalse
tabIndexSets the tab order for the field.numberundefined
autoCompleteControls browser autocomplete for the field.HTMLInputAttributes["autocomplete"]off
separatorSeparator, also ConfigProvider.rangePicker.separator.string | SnippetArrow

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.

DatePicker Component Tokens
TokenPurpose
activeBgActive field background.
activeBorderColorActive frame.
activeShadowFocus shadow.
addonBgBackground of the additional area.
cellActiveWithRangeBgSelected range.
cellBgDisabledUnavailable day background.
cellHeightCell height.
cellHoverBgTargeting a cell.
cellHoverWithRangeBgPreliminary range.
cellRangeBorderColorRange frame.
cellWidthCell width.
errorActiveShadowError shadow.
hoverBgField background when hovering.
hoverBorderColorHover frame.
inputFontSizeMiddle field text.
inputFontSizeLGLarge field text.
inputFontSizeSMSmall field text.
multipleItemBgMultiple tag background.
multipleItemBorderColorMultiple tag frame.
multipleItemBorderColorDisabledInaccessible multiple tag frame.
multipleItemColorDisabledInaccessible multiple tag text.
multipleItemHeightHeight of multiple tag.
multipleItemHeightLGLarge multiple tag.
multipleItemHeightSMSmall multiple tag.
multipleSelectorBgDisabledInaccessible multiple-selector.
paddingBlockVertical offset.
paddingBlockLGLarge margin indent.
paddingBlockSMSmall margin indent.
paddingInlineHorizontal offset.
paddingInlineLGLarge margin indent.
paddingInlineSMSmall margin indent.
presetsMaxWidthMaximum width of presets.
presetsWidthWidth presets.
textHeightText height.
timeCellHeightTime variant height.
timeColumnHeightHeight of the time column.
timeColumnWidthTime column width.
warningActiveShadowShadow warning.
withoutTimeCellHeightDay altitude without time.
zIndexPopupLayer popup.

Common tokens of the current topic

Names are checked against the common table ant.design; the current values ​​are read via theme.useToken().

Common tokens of the current topic
TokenMeaning
colorBgContainer#ffffff
colorBgContainerDisabledrgba(0,0,0,0.04)
colorBgElevated#ffffff
colorBorder#d9d9d9
colorBorderDisabled#d9d9d9
colorError#ff4d4f
colorErrorAffix#ff4d4f
colorErrorBg#fff2f0
colorErrorBgHover#fff1f0
colorErrorBorderHover#ffa39e
colorErrorText#ff4d4f
colorFillSecondaryrgba(0,0,0,0.06)
colorFillTertiaryrgba(0,0,0,0.04)
colorIconrgba(0,0,0,0.45)
colorIconHoverrgba(0,0,0,0.88)
colorLink#1677ff
colorLinkActive#0958d9
colorLinkHover#69b1ff
colorPrimary#2f54eb
colorPrimaryBorder#adc6ff
colorSplitrgba(5,5,5,0.06)
colorTextrgba(0,0,0,0.88)
colorTextDisabledrgba(0,0,0,0.25)
colorTextHeadingrgba(0,0,0,0.88)
colorTextLightSolid#fff
colorTextPlaceholderrgba(0,0,0,0.25)
colorTextQuaternaryrgba(0,0,0,0.25)
colorTextTertiaryrgba(0,0,0,0.45)
colorWarning#faad14
colorWarningAffix#faad14
colorWarningBg#fffbe6
colorWarningBgHover#fff1b8
colorWarningBorderHover#ffd666
colorWarningText#faad14
borderRadius6
borderRadiusLG8
borderRadiusSM4
borderRadiusXS2
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)
controlHeight32
controlHeightLG40
controlHeightSM24
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'
fontSize14
fontSizeLG16
fontSizeSM12
fontWeightStrong600
lineHeight1.5714285714285714
lineHeightLG1.5
lineTypesolid
lineWidth1
lineWidthBold2
linkDecorationnone
linkFocusDecorationnone
linkHoverDecorationnone
marginXS8
marginXXS4
motionDurationMid0.2s
motionDurationSlow0.3s
motionEaseInOutCirccubic-bezier(0.78, 0.14, 0.15, 0.86)
motionEaseInQuintcubic-bezier(0.755, 0.05, 0.855, 0.06)
motionEaseOutCirccubic-bezier(0.08, 0.82, 0.17, 1)
motionEaseOutQuintcubic-bezier(0.23, 1, 0.32, 1)
padding16
paddingSM12
paddingXS8
paddingXXS4
sizePopupArrow16

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.