Date Picker
Enter a date, time, or range directly, or choose it from a calendar.
Usage guide
#Use for date and time selection. Choose variant to match the required value.
Write the error message in the error slot.
Inside the component, add <span slot="error">Error message</span>. You can include links and other guidance as well as text. For inputs supporting noNativeValidity, enable it to show this guidance instead of a browser popup. Switch always displays errors below the component.
Report business rule failures with setCustomError().
For example, if the server rejects a duplicate value, update the error slot and call setCustomError(). This method does not take a message argument. A custom error also blocks form submission.
Clear the error after resolving it and check whether submission is allowed.
Use clearCustomError() to clear a business rule error. Required-field and format validation remain active. await checkValidity() returns true or false; reportValidity() validates and displays errors. Read valid named values through FormData on submission.
Date
Use date. Set the day, month, or year selection unit with mode.
Date and time
Use datetime to select both a date and a time.
Range
Use range to collect a start and end date.
Time
Use time to select a time without a date.
- Display and form integration
formatusesyyyy,MM,dd,hh,mm, andss. Connect forms withnameandrequired.selectedreports confirmed selection;changedreports input changes.
Examples
#Feature examples
#Choose a feature from 14 topics. Explore property settings, method calls, event results, and slot layouts through live examples and code.
No matching features.
API reference
#Hover over a name or focus it with the keyboard to see the code. On touch screens, tap the name.
<sy-datepicker>
Properties
| Attribute / Property | Type | Default | Description |
|---|---|---|---|
'day' | 'month' | 'year' | 'day' | Date selection unit: day, month, or year. | |
'date' | 'datetime' | 'range' | 'time' | 'date' | Selection type: date, date and time, range, or time. | |
boolean | false | Block user interaction and keyboard focus. | |
boolean | false | Display the current value while preventing edits. | |
boolean | false | Fail form validation when no value is provided. | |
string | undefined | Year. | |
string | undefined | Month. Date Picker uses 1–12; child Calendar components use 0–11. | |
string | undefined | Day of the month. | |
string | undefined | Hour, from 0 to 23. | |
string | undefined | Minute, from 0 to 59. | |
string | undefined | Second, from 0 to 59. | |
string | 'Su,Mo,Tu,We,Th,Fr,Sa' | Comma-separated weekday names, from Sunday through Saturday. | |
boolean | false | Start the week on Monday. | |
boolean | false | Hide Saturdays and Sundays in the calendar. | |
string | '' | Placeholder shown when the value is empty. | |
string | 'yyyy-MM-dd hh:mm:ss' | Display format combining the yyyy, MM, dd, hh, mm, and ss tokens. | |
string | '' | Field name used in FormData. | |
boolean | false | Use the app's error UI instead of the browser's built-in error display. checkValidity still performs validation. |
Events
| Event | Detail | Description |
|---|---|---|
CustomEvent<unknown> | Emitted when the value or selection state changes. | |
CustomEvent<unknown> | Emitted when the user selects an item. |
Methods
| Method | Returns | Description |
|---|---|---|
Promise<string> | Return the current validation state. | |
Promise<void> | Set a custom error state. | |
Promise<void> | Clear the custom error state. | |
Promise<boolean> | Return true if the current constraints are satisfied, otherwise false. | |
Promise<boolean> | Validate the current value and display errors to the user. |
Slots
| Slot | Description |
|---|---|
| Validation error message. |
<sy-calendar>
Properties
| Attribute / Property | Type | Default | Description |
|---|---|---|---|
'day' | 'month' | 'year' | 'day' | Date selection unit: day, month, or year. | |
'date' | 'datetime' | 'range' | 'time' | 'date' | Panel to display: date, date and time, range, or time. | |
string | 'hh:mm:ss' | Format used to display and parse values. See the usage guide for tokens or format values. | |
string | undefined | Range endpoint currently being edited: start or end. | |
number | undefined | Year. | |
number | undefined | Month. Date Picker uses 1–12; child Calendar components use 0–11. | |
number | undefined | Day of the month. | |
number | undefined | Hour, from 0 to 23. | |
number | undefined | Minute, from 0 to 59. | |
number | undefined | Second, from 0 to 59. | |
{year: number, month: number, day: number } | undefined | Start date of the selected range. month is zero-based. Pass objects and arrays as JavaScript properties. | |
{year: number, month: number, day: number } | undefined | End date of the selected range. month is zero-based. Pass objects and arrays as JavaScript properties. | |
string | 'Su,Mo,Tu,We,Th,Fr,Sa' | Comma-separated weekday names, from Sunday through Saturday. | |
boolean | false | Start the week on Monday. | |
boolean | false | Hide Saturdays and Sundays in the calendar. |
Events
| Event | Detail | Description |
|---|---|---|
CustomEvent<unknown> | Emitted when the user selects an item. | |
CustomEvent<unknown> | Read the result from the event's detail. |
<sy-date-calendar>
Properties
| Attribute / Property | Type | Default | Description |
|---|---|---|---|
'day' | 'month' | 'year' | 'decade' | undefined | Day, month, year, or decade view. | |
{year: number, month: number, day: number, hour: number, minute: number, second: number} | {
year: new Date().getFullYear(),
month: new Date().getMonth(),
day: new Date().getDate(),
hour: new Date().getHours(),
minute: new Date().getMinutes(),
second: new Date().getSeconds()
} | Object containing year, month, day, hour, minute, and second. month is zero-based. Pass objects and arrays as JavaScript properties. | |
'start' | 'end' | undefined | Assign the start or end role in range selection. | |
string | undefined | Range endpoint currently being edited: start or end. | |
{year: number, month: number, day: number } | undefined | Start date of the selected range. month is zero-based. Pass objects and arrays as JavaScript properties. | |
{year: number, month: number, day: number } | undefined | End date of the selected range. month is zero-based. Pass objects and arrays as JavaScript properties. | |
string | undefined | Date under the pointer during range selection. | |
string | 'Su,Mo,Tu,We,Th,Fr,Sa' | Comma-separated weekday names, from Sunday through Saturday. | |
boolean | false | Start the week on Monday. | |
boolean | false | Hide Saturdays and Sundays in the calendar. | |
Date | new Date() | Reference date for the current calendar view, passed as a Date object. Pass objects and arrays as JavaScript properties. |
Events
| Event | Detail | Description |
|---|---|---|
CustomEvent<unknown> | Emitted when the value or selection state changes. | |
CustomEvent<unknown> | Emitted when the user selects an item. | |
CustomEvent<unknown> | Read the result from the event's detail. | |
CustomEvent<unknown> | Read the result from the event's detail. |
<sy-date-time-calendar>
Properties
| Attribute / Property | Type | Default | Description |
|---|---|---|---|
'day' | 'month' | 'year' | 'decade' | 'day' | Day, month, year, or decade view. | |
{year: number, month: number, day: number, hour: number, minute: number, second: number} | {
year: new Date().getFullYear(),
month: new Date().getMonth(),
day: new Date().getDate(),
hour: new Date().getHours(),
minute: new Date().getMinutes(),
second: new Date().getSeconds()
} | Object containing year, month, day, hour, minute, and second. month is zero-based. Pass objects and arrays as JavaScript properties. | |
string | 'Su,Mo,Tu,We,Th,Fr,Sa' | Comma-separated weekday names, from Sunday through Saturday. | |
boolean | false | Start the week on Monday. | |
boolean | false | Hide Saturdays and Sundays in the calendar. |
Events
| Event | Detail | Description |
|---|---|---|
CustomEvent<unknown> | Emitted when the user selects an item. |
<sy-range-calendar>
Properties
| Attribute / Property | Type | Default | Description |
|---|---|---|---|
'day' | 'month' | 'year' | undefined | Day, month, or year view. | |
string | undefined | Endpoint currently being edited: start or end. | |
{year: number, month: number, day: number, hour: number, minute: number, second: number} | undefined | Object containing year, month, day, hour, minute, and second. month is zero-based. Pass objects and arrays as JavaScript properties. | |
{ year: number, month: number, day: number } | undefined | Start date of the selected range. month is zero-based. Pass objects and arrays as JavaScript properties. | |
{ year: number, month: number, day: number } | undefined | End date of the selected range. month is zero-based. Pass objects and arrays as JavaScript properties. | |
string | 'Su,Mo,Tu,We,Th,Fr,Sa' | Comma-separated weekday names, from Sunday through Saturday. | |
boolean | false | Start the week on Monday. | |
boolean | false | Hide Saturdays and Sundays in the calendar. |
Events
| Event | Detail | Description |
|---|---|---|
CustomEvent<unknown> | Emitted when the user selects an item. |
<sy-timepicker>
Properties
| Attribute / Property | Type | Default | Description |
|---|---|---|---|
number | 0 | Hour, from 0 to 23. | |
number | 0 | Minute, from 0 to 59. | |
number | 0 | Second, from 0 to 59. | |
boolean | false | Hide the time selection panel's confirmation button. | |
string | ':' | Separator character between time units. | |
string | 'hh:mm:ss' | Format used to display and parse values. See the usage guide for tokens or format values. |
Events
| Event | Detail | Description |
|---|---|---|
CustomEvent<unknown> | Emitted when the user selects an item. | |
CustomEvent<unknown> | Emitted when the value or selection state changes. |