Date Input
<sl-date-input> | SlDateInput
            Date input field
The date input supports the following shortcuts:
- ‘T’ - today
- ‘Y’ - yesterday
- ‘-{n}’ - n days before currently entered date where n is an integer. If currently entered date is empty, will use today’s date.
- ‘+{n}’ - similar to ‘-{n}’, but after.
- ‘-{n}w’ - n weeks before currently entered date where n is an integer. If currently entered date is empty, will use today’s date.
- ‘+{n}w’ - similar to ‘-{n}w’, but after.
- ‘-{n}m’ - n months before currently entered date where n is an integer. If currently entered date is empty, will use today’s date.
- ‘+{n}m’ - similar to ‘-{n}y’, but after.
- ‘-{n}y’ - n years before currently entered date where n is an integer. If currently entered date is empty, will use today’s date.
- ‘+{n}y’ - similar to ‘-{n}y’, but after.
<sl-date-input></sl-date-input>
Examples
Hiding the calendar
Use show-calendar="no" to hide the calendar
<sl-date-input show-calendar="no"></sl-date-input>
Setting value
Use value in YYYY-MM-DD format to set value.
<sl-date-input value="2024-01-01"></sl-date-input>
Configuring the label
Use the label and stacked attributes as per a normal input field
<sl-date-input label="My label"></sl-date-input> <sl-date-input label="My stacked label" stacked></sl-date-input>
Required options
Use the required attribute as per a normal input field
<sl-date-input label="Required date" required></sl-date-input>
[component-metadata:sl-date-input]
Properties
| Name | Description | Reflects | Type | Default | 
|---|---|---|---|---|
| label | The label for the date input field | string | '' | |
| stacked | Whether the label should always be stacked | boolean | false | |
| required | Whether the date input is required | boolean | false | |
| showQuarters show-quarters  | Show side panel presets for financial year quarters | boolean | - | |
| showFinancialYears show-financial-years  | Show side panel presets for financial years | boolean | - | |
| value | The value | string | '' | |
| valueFrom | The value of the date range input field from |  | string | '' | 
| valueTo | The value of the date range input field to |  | string | '' | 
| isFromValue | Used for date range | boolean | false | |
| isToValue | Used for date range | boolean | false | |
| showCalendar show-calendar  | Show calendar? Use ‘no’ to stop the calendar from appearing | 'yes' | 'no' | 'yes' | |
| updateComplete | A read-only promise that resolves when the component has finished updating. | 
Learn more about attributes and properties.
Events
| Name | React Event | Description | Event Detail | 
|---|---|---|---|
| sl-change |  | When the date value is changed | - | 
| select-range |  | Emitted when the ‘from’ date is selected to prime the ‘to’ date for date range input. | - | 
Learn more about events.
Dependencies
This component automatically imports the following dependencies.
- <sl-icon>
- <sl-input>