Component Blueprints
Datetime Picker
- HTML/CSS:Dev Ready
- Layout:Desktop Only
Sections
A datetime picker is used to select a day and a time.
About datetime picker#
Implementation#
The datetime is two form elements, each containing a label and text input, and a dropdown menu, containing a grid-based calendar and filters. The date form element acts as a trigger for the dropdown.
Placement of inline form elements inside a data table cell is not supported. Instead, use a button to invoke a popover, which does support form elements.
The datetime picker has the following markup requirements:
All
- Follow all accessibility requirements mentioned in the Datepicker and Timepicker blueprints.
Desktop
- Add
.slds-is-open
to the element with.slds-dropdown-trigger
to invoke the dropdown that contains the datepicker and the list of time options. - On the timepicker, the
.slds-has-focus
modifier class is required on the.slds-listbox__option
element that has focus. - On the timepicker, the
.slds-is-selected
modifier class is required on the.slds-listbox__option
element that has been selected. - On the datepicker, the
.slds-is-selected
modifier class is required on thetd
element that has the selected day. - On the datepicker, the
.slds-is-today
modifier class is required on thetd
element that is the current day.
Mobile
- When on mobile, we want to leverage the native datetime picker by changing the
input
type fromtext
todatetime-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
, andaria-haspopup
. - On the
input
that we just addedtype="datetime-local"
to, please removearia-controls
,aria-autocomplete
, androle="textbox"
.
- On the element with the class
Base#
<div class="slds-form">
<fieldset class="slds-form-element slds-form-element_compound">
<legend class="slds-form-element__label slds-form-element__legend">Date and Time</legend>
<div class="slds-form-element__control">
States#
Adding slds-datetimepicker_has-tooltip
to the element with slds-form-element_compound
aligns the legend properly when there is an info tooltip.
Date selection#
<div class="slds-form">
<fieldset class="slds-form-element slds-form-element_compound">
<legend class="slds-form-element__label slds-form-element__legend">Date and Time</legend>
<div class="slds-form-element__control">
Time selection#
<div class="slds-form">
<fieldset class="slds-form-element slds-form-element_compound">
<legend class="slds-form-element__label slds-form-element__legend">Date and Time</legend>
<div class="slds-form-element__control">
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 |
Datetime Picker Release Notes
2.22.0
Added
- Tooltip option provided for Date/DateTime pickers.
- Added
slds-datetimepicker_has-tooltip
class to fix the icon misalignment issue.
2.17.0
Fixed
- Fixed missing attribute
required
on date input
2.16.0
Added
- Added
aria-label
to provide the fullDD MM YYYY
text of the date
Added
- Added hover style for dates
Changed
- Removed the usage of the deprecated combobox. The Datetime Picker now uses the current combobox.
2.13.0
Changed
- Datetime Picker blueprints no longer use the deprecated variant
.slds-form_compound
on its parent.slds-form
. Instead, it now uses.slds-form-element_compound
on its parent.slds-form-element
.