Skip to main content

Date picker

The date picker component allows merchants to select dates using a calendar interface. Use it when merchants benefit from seeing dates in context of the full month, such as selecting dates relative to today or needing weekday context.

The component supports single dates, multiple dates, and date ranges. Time selection isn't supported. For text date entry, use date field.

Support
Targets (29)

Configure the following properties on the date picker component.

Anchor to allow
allow
string
Default: ""

Restricts which dates the user can select. Accepts a comma-separated list of dates and date ranges. Whitespace is allowed after commas.

The default '' allows all dates.

  • Dates in YYYY-MM-DD format allow a single date.
  • Dates in YYYY-MM format allow a whole month.
  • Dates in YYYY format allow a whole year.
  • Ranges are expressed as start--end. - Ranges are inclusive.
    • If either start or end is omitted, the range is unbounded in that direction.
    • If parts of the date are omitted for start, they are assumed to be the minimum possible value. So 2024-- is equivalent to 2024-01-01--.
    • If parts of the date are omitted for end, they are assumed to be the maximum possible value. So --2024 is equivalent to --2024-12-31.
    • Whitespace is allowed either side of --.

Comma-separated list of allowed dates in YYYY-MM-DD format.

Anchor to allowDays
allowDays
string
Default: ""

Restricts which days of the week the user can select. Only dates that fall on an allowed day AND pass the allow/disallow filters are selectable. For example, setting allowedDays to 'mon, wed, fri' with allow set to '2024-06' restricts selection to Mondays, Wednesdays, and Fridays in June 2024.

A comma-separated list of days. Whitespace is allowed after commas.

The default '' has no effect on the result of allow and disallow.

Days are sunday, monday, tuesday, wednesday, thursday, friday, saturday.

Anchor to defaultValue
defaultValue
string
Default: ""

Default selected value.

The default means no date is selected.

If the provided value is invalid, no date is selected.

  • If type="single", this is a date in YYYY-MM-DD format.
  • If type="multiple", this is a comma-separated list of dates in YYYY-MM-DD format.
  • If type="range", this is a range in YYYY-MM-DD--YYYY-MM-DD format. The range is inclusive.
Anchor to defaultView
defaultView
string

Default month to display in YYYY-MM format.

This value is used until view is set, either directly or as a result of user interaction.

Defaults to the current month in the user's locale.

Anchor to disabled
disabled
boolean
Default: false

Whether the field is disabled, preventing any user interaction.

Anchor to disallow
disallow
string
Default: ""

Dates that cannot be selected. These subtract from allow.

A comma-separated list of dates, date ranges. Whitespace is allowed after commas.

The default '' has no effect on allow.

  • Dates in YYYY-MM-DD format disallow a single date.
  • Dates in YYYY-MM format disallow a whole month.
  • Dates in YYYY format disallow a whole year.
  • Ranges are expressed as start--end. - Ranges are inclusive.
    • If either start or end is omitted, the range is unbounded in that direction.
    • If parts of the date are omitted for start, they are assumed to be the minimum possible value. So 2024-- is equivalent to 2024-01-01--.
    • If parts of the date are omitted for end, they are assumed to be the maximum possible value. So --2024 is equivalent to --2024-12-31.
    • Whitespace is allowed either side of --.

Comma-separated list of disallowed dates in YYYY-MM-DD format.

Anchor to disallowDays
disallowDays
string
Default: ""

Days of the week that cannot be selected. This subtracts from allowDays, and intersects with the result of allow and disallow.

A comma-separated list of days. Whitespace is allowed after commas.

The default '' has no effect on allowDays.

Days are sunday, monday, tuesday, wednesday, thursday, friday, saturday.

string

A unique identifier for the element. Use this to reference the element in JavaScript, link labels to form controls, or target specific elements for styling or scripting.

string

The name attribute for the field, used to identify the field's value when the form is submitted. Must be unique within the nearest containing form.

'single' | 'multiple' | 'range'
Default: "single"

The type of selection the date picker allows.

  • single allows selecting a single date.
  • multiple allows selecting multiple non-contiguous dates.
  • range allows selecting a single range of dates.
Anchor to value
value
string
Default: ""

Current selected value.

The default means no date is selected.

If the provided value is invalid, no date is selected.

Otherwise:

  • If type="single", this is a date in YYYY-MM-DD format.
  • If type="multiple", this is a comma-separated list of dates in YYYY-MM-DD format.
  • If type="range", this is a range in YYYY-MM-DD--YYYY-MM-DD format. The range is inclusive.

Single dates use ISO 8601 format (YYYY-MM-DD); ranges use YYYY-MM-DD--YYYY-MM-DD. Locale-specific formats aren't supported.

string

Displayed month in YYYY-MM format.

onViewChange is called when this value changes.

Defaults to defaultView.

The date picker component provides event callbacks for handling user interactions. Learn more about handling events.

<typeof tagName>

A callback fired when the date picker loses focus.

Learn more about the blur event.

Anchor to change
change
<typeof tagName>

A callback fired when the date picker value changes.

Learn more about the change event.

Anchor to focus
focus
<typeof tagName>

A callback fired when the date picker receives focus.

Learn more about the focus event.

Anchor to input
input
<typeof tagName>

A callback fired when the user inputs data into the date picker.

Learn more about the input event.

Anchor to viewChange
viewChange
<typeof tagName>

A callback fired when the calendar view changes, such as when navigating between months.


Anchor to Select a date from a calendarSelect a date from a calendar

Display a visual calendar for date selection with a pre-selected date. This example configures an s-date-picker with defaultView set to a month and defaultValue highlighting a specific day.

Select a date from a calendar

A rendered example of the date-picker component

html

<s-date-picker defaultView="2027-10" defaultValue="2027-10-03"></s-date-picker>

Anchor to Restrict selectable calendar datesRestrict selectable calendar dates

Block dates before a cutoff and exclude Sundays from the calendar. This example shows an s-date-picker with disallow set to dates before December 1, 2026 and disallowDays excluding Sundays.

html

<s-date-picker
defaultView="2026-12"
disallow="--2026-12-01"
disallowDays="sunday"
></s-date-picker>

Allow buyers to pick a start and end date for a booking or subscription window. This example uses an s-date-picker with type set to range.

html

<s-date-picker
defaultView="2026-06"
type="range"
></s-date-picker>

  • Set a default view: Use defaultView to open the calendar to the most relevant month, such as the current or next month.
  • Restrict invalid dates: Use disallow with date ranges and disallowDays with day names to prevent buyers from selecting unavailable dates.
  • Choose the right selection mode: Use type="range" for booking windows and the default single mode for one-off date selections.

Was this page helpful?