Without sbb-form-field
, with all related components:
<sbb-datepicker-previous-day date-picker="datepicker"></sbb-datepicker-previous-day>
<sbb-datepicker-toggle date-picker="datepicker"></sbb-datepicker-toggle>
<input id="datepicker-input" />
<sbb-datepicker input="datepicker-input" id="datepicker"></sbb-datepicker>
<sbb-datepicker-next-day date-picker="datepicker"></sbb-datepicker-next-day>
With sbb-form-field
, and input params set:
<sbb-form-field>
<input min="1600000000" max="1700000000" value="01.01.2023" readonly=""/>
<sbb-datepicker></sbb-datepicker>
</sbb-form-field>
With sbb-form-field
and all related components, input's value set, wide
set to true:
<sbb-form-field>
<sbb-datepicker-previous-day></sbb-datepicker-previous-day>
<sbb-datepicker-toggle></sbb-datepicker-toggle>
<input value="01.01.2023"/>
<sbb-datepicker wide></sbb-datepicker>
<sbb-datepicker-next-day></sbb-datepicker-next-day>
</sbb-form-field>
To specify a specific date for the current datetime, you can use the data-now
attribute (timestamp in milliseconds).
This is helpful if you need a specific state of the component.
Property | Attribute | Description | Type | Default |
---|---|---|---|---|
dateFilter | -- | A function used to filter out dates. | (date: Date) => boolean | () => true |
dateParser | -- | A function used to parse string value into dates. | (value: string) => Date | undefined |
format | -- | A function used to format dates into the preferred string format. | (date: Date) => string | undefined |
input | input | Reference of the native input connected to the datepicker. | HTMLElement | string | undefined |
wide | wide | If set to true, two months are displayed | boolean | false |
Event | Description | Type |
---|---|---|
change | CustomEvent<any> | |
datePickerUpdated | Notifies that the attributes of the datepicker has changes. | CustomEvent<any> |
didChange | [DEPRECATED] only used for React. Will probably be removed once React 19 is available. | CustomEvent<any> |
inputUpdated | Notifies that the attributes of the input connected to the datepicker has changes. | CustomEvent<InputUpdateEvent> |
validationChange | Emits whenever the internal validation state changes. | CustomEvent<ValidationChangeEvent> |
getValueAsDate() => Promise<Date>
Gets the input value with the correct date format.
Type: Promise<Date>
setValueAsDate(date: Date | number | string) => Promise<void>
Set the input value to the correctly formatted value.
Type: Promise<void>