Skip to content

Commit 41c1a1b

Browse files
nikkimkcaseyisonit
andauthored
docs(picker): updated docs with allowed menu content (#5446)
* docs(picker): updated docs with allowed menu content * docs(picker): fixed types * docs(picker): fixed typo Co-authored-by: Casey Eickhoff <[email protected]> * docs(picker): fixed typos Co-authored-by: Casey Eickhoff <[email protected]> --------- Co-authored-by: Casey Eickhoff <[email protected]>
1 parent ba4e9bd commit 41c1a1b

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

packages/picker/README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ import { Picker } from '@spectrum-web-components/picker';
3232
3333
### Anatomy
3434
35+
A picker includes a label and a menu.
36+
3537
#### Labels
3638
3739
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
9193
</sp-tab-panel>
9294
</sp-tabs>
9395
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+
94122
#### Icons
95123
96124
`<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:
660688

661689
</sp-tab-panel>
662690
</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

Comments
 (0)