Datetime Picker
Datetime Picker
- HTML/CSS:Dev Ready
- Layout:Desktop Only
A datetime picker is used to select a day and a time.
Base
Preview
About Datetime Picker
Implementation Notes and Requirements
The datetime picker has the following markup requirements:
Desktop
- Add
.slds-is-opento the element with.slds-dropdown-triggerto invoke the dropdown that contains the datepicker and the list of time options. - On the timepicker, the
.slds-has-focusmodifier class is required on the.slds-listbox__optionelement that has focus. - On the timpicker, the
.slds-is-selectedmodifier class is required on the.slds-listbox__optionelement that has been selected. - On the datepicker, the
.slds-is-selectedmodifier class is required on thetdelement that has the selected day. - On the datepicker, the
.slds-is-todaymodifier class is required on thetdelement that is the current day.
Mobile
- When on mobile, we want to leverage the native datetime picker by changing the
inputtype fromtexttodatetime-local - The
input type="datetime-local"will create an input field allowing a date and time to be easily entered — this includes year, month, day, hours, and minutes. - When switching
input type="text"toinput type="datetime-local"for mobile, we need to remove the ARIA attributes. The native rendering doesn't require these.- On the element with the class
slds-combobox, please removerole="combobox",aria-expanded, and `aria-haspopup. - On the
inputthat we just addedtype="datetime-local"to, please removearia-controls,aria-autocomplete, androle="textbox".
- On the element with the class
Overview of CSS Classes
- Selector
- The CSS class being referred to.
- Summary
- A description of what the class does.
- Support
- Whether the class name is dev-ready (meaning it's fully vetted and tested and safe to use) or prototype (which means it's not fully vetted yet).
- Restrict
- The selector that the class name is allowed to be used on.
- Variant
- The base level pattern for a component. A variant can be extended to create another variant of that component, for example, a stateful button is a derivative of the base button.
- Modifier
- A single class that can be added to an HTML element of a component to modify its output. Typically these will be colors, sizing and positioning.
| Selector | .slds-datetime-picker |
|---|---|
| Summary | Initializes a datetime picker |
| Support | dev-ready |
| Restrict | div |
| Variant | True |