You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/picker/README.md
+32Lines changed: 32 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -32,6 +32,8 @@ import { Picker } from '@spectrum-web-components/picker';
32
32
33
33
### Anatomy
34
34
35
+
A picker includes a label and a menu.
36
+
35
37
#### Labels
36
38
37
39
To render accessibly, an `<sp-picker>` element should be paired with an `<sp-field-label>` element that has the `for` attribute referencing the `id` of the `<sp-picker>` element.
@@ -91,6 +93,32 @@ For an accessible label that renders within the bounds of the picker itself, but
91
93
</sp-tab-panel>
92
94
</sp-tabs>
93
95
96
+
#### Menu
97
+
98
+
The picker menu is a menu element that is used to display the options for the picker. A picker menu can include menu items, menu dividers, and menu groups. A picker menu should never contain submenus, as doing so would render it inaccessible.
99
+
100
+
If you require a submenu, use and [action menu](./action-menu) instead of a picker.
101
+
102
+
```html demo
103
+
<sp-picker>
104
+
<span slot="label">Select a free food item:</span>
105
+
<sp-menu-group>
106
+
<span slot="header">Fruits</span>
107
+
<sp-menu-item>Apple</sp-menu-item>
108
+
<sp-menu-item>Banana</sp-menu-item>
109
+
<sp-menu-item>Pear</sp-menu-item>
110
+
</sp-menu-group>
111
+
<sp-menu-divider></sp-menu-divider>
112
+
<sp-menu-group>
113
+
<span slot="header">Vegetables</span>
114
+
<sp-menu-item>Artichoke</sp-menu-item>
115
+
<sp-menu-item>Carrot</sp-menu-item>
116
+
<sp-menu-item>Potato</sp-menu-item>
117
+
</sp-menu-group>
118
+
<sp-menu-group>
119
+
</sp-picker>
120
+
```
121
+
94
122
#### Icons
95
123
96
124
`<sp-menu-item>`s in an `<sp-picker>` that are provided content addressed to their `icon` slot will be passed to the `<sp-picker>` element when that item is chosen.
@@ -660,3 +688,7 @@ Use [`<sp-help-text>`](../help-text/) to add help text and error text:
660
688
661
689
</sp-tab-panel>
662
690
</sp-tabs>
691
+
692
+
#### Do not use submenus
693
+
694
+
A picker menu should never contain submenus, as doing so would render it inaccessible. A picker's menu role is a listbox, and its menu items are listbox options, which are not allowed to have submenus.
0 commit comments