Picklist
- HTML/CSS:Dev Ready
- Layout:Desktop Only
Sections
- Option A
- Option B
- Option ABCDEFGHIJKLMNOPQRSTUVWXYZ
About Picklist#
A picklist is a widget that displays a list of selectable options. When an option is selected, it is shown as selected and the value of the read-only input is updated to match it.
A multi-select picklist is a widget that displays a list of selectable options, where more than one option can be chosen. When more than one option has been selected, the value of the read-only input should update with the total number of selected items, such as "3 options selected". When a picklist with multiple selected options is closed, a listbox of pills is also used to represent those selected options. The listbox of pills is positioned below the read-only input, each pill represents a selected option. This allows a user to easily see and remove selected items.
The target HTML element, slds-combobox
and dropdown need to be wrapped in the class .slds-dropdown-trigger dropdown-trigger_click
.
Accessibility#
A Picklist allows a user to select and set a value from a pre-defined list of options. As such we follow the ARIA Combobox widget pattern to implement it as it's the most appropriate concept to achieve this. The variant of Combobox we chose is the "Read-only" version, as a users keyboard input cannot directly affect the value set in the Combobox, but can only select a value from a pre-defined list. It also does not perform a search, or autocomplete function. It most closely resembles the HTML select
element.
Implementing a multi-select pattern with a Combobox is not standard, nor is it technically supported by the specification. Therefore great care should be paid to the extra steps we take to try and communicate multi-selection.
Please refer to the Combobox documentation relating to read-only implementation guidelines.
Default#
A Picklist provides a user with an read-only input field that is accompanied with a listbox of pre-defined options. A picklist has a single and multi-selection pattern.
- Option A
- Option B
- Option ABCDEFGHIJKLMNOPQRSTUVWXYZ
<div class="slds-form-element">
<label class="slds-form-element__label" for="combobox-id-1" id="combobox-label-id-4">Relate To</label>
<div class="slds-form-element__control">
<div class="slds-combobox_container slds-size_small">
States#
Focused#
- Option A
- Option B
- Option ABCDEFGHIJKLMNOPQRSTUVWXYZ
<div class="slds-form-element">
<label class="slds-form-element__label" for="combobox-id-2" id="combobox-label-id-7">Relate To</label>
<div class="slds-form-element__control">
<div class="slds-combobox_container slds-size_small">
Open - Item Focused#
- Option A
- Option B
- Option ABCDEFGHIJKLMNOPQRSTUVWXYZ
<div class="slds-form-element">
<label class="slds-form-element__label" for="combobox-id-3" id="combobox-label-id-10">Relate To</label>
<div class="slds-form-element__control">
<div class="slds-combobox_container slds-size_small">
Open - Option Selected#
- Option A
- Option B
- Option ABCDEFGHIJKLMNOPQRSTUVWXYZ
<div class="slds-form-element">
<label class="slds-form-element__label" for="combobox-id-4" id="combobox-label-id-13">Relate To</label>
<div class="slds-form-element__control">
<div class="slds-combobox_container slds-size_small">
Open - Options Selected#
- Option A
- Option B
- Option ABCDEFGHIJKLMNOPQRSTUVWXYZ
<div class="slds-form-element">
<label class="slds-form-element__label" for="combobox-id-5" id="combobox-label-id-16">Relate To</label>
<div class="slds-form-element__control">
<div class="slds-combobox_container slds-size_small">
Closed - Option Selected#
- Option A
- Option B
- Option ABCDEFGHIJKLMNOPQRSTUVWXYZ
<div class="slds-form-element">
<label class="slds-form-element__label" for="combobox-id-6" id="combobox-label-id-19">Relate To</label>
<div class="slds-form-element__control">
<div class="slds-combobox_container slds-size_small">
Closed - Options Selected#
- Option A
- Option B
- Option ABCDEFGHIJKLMNOPQRSTUVWXYZ
- Option A
- Option B
<div class="slds-form-element">
<label class="slds-form-element__label" for="combobox-id-7" id="combobox-label-id-22">Relate To</label>
<div class="slds-form-element__control">
<div class="slds-combobox_container slds-size_small">
Examples#
Group heading label#
Recently Viewed
- Option A
- Option B
<div class="slds-form-element">
<label class="slds-form-element__label" for="combobox-id-8" id="combobox-label-id-25">Relate To</label>
<div class="slds-form-element__control">
<div class="slds-combobox_container slds-size_small">
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-combobox-picklist |
---|---|
Summary | |
Restrict | div |
Variant | True |
Picklist Release Notes
2.21.0
Added
- Added aria-label and tabindex to fix aria-allowed-attr and aria-label sa11y issue.
2.21.0
Added
- Added
aria-label
for picklist examples to meet accessibility requirements.
2.16.0
Changed
- Removed the usage of the deprecated combobox. The Picklist now uses the current combobox.
2.13.1
Fixed
- Small improvements to the UI text.
2.10.0
Added
- Added
.slds-picklist input[readonly]
selector to fix styling of deprecated markup
Changed
- Migrated picklist HTML to use non-deprecated combobox
2.8.0
Added
- Added
slds-listbox__option-header
to increase font size to 14px, and apply bold font weight, on listbox option headers.
Removed
- Removed
slds-text-title_caps
from listbox option headers.