-
Notifications
You must be signed in to change notification settings - Fork 233
docs(picker): updated docs with allowed menu content #5446
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
4194208
42cbf31
9dc004d
261d866
d9f8121
1463cad
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,6 +32,8 @@ import { Picker } from '@spectrum-web-components/picker'; | |
|
||
### Anatomy | ||
|
||
A picker includes a label and a menu.. | ||
nikkimk marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
#### Labels | ||
|
||
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 | |
</sp-tab-panel> | ||
</sp-tabs> | ||
|
||
#### Menu | ||
|
||
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. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Notes that submenus would make a picker inaccessible. |
||
|
||
If you require a submenu, use and [action menu](./action-menu) instead of a picker. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎶 I loveeeeee this so much |
||
|
||
```html demo | ||
<sp-picker> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Example with menu groups since picker can accept them. |
||
<span slot="label">Select a free food item:</span> | ||
<sp-menu-group> | ||
<span slot="header">Fruits</span> | ||
<sp-menu-item>Apple</sp-menu-item> | ||
<sp-menu-item>Banana</sp-menu-item> | ||
<sp-menu-item>Pear</sp-menu-item> | ||
</sp-menu-group> | ||
<sp-menu-divider></sp-menu-divider> | ||
<sp-menu-group> | ||
<span slot="header">Vegetables</span> | ||
<sp-menu-item>Artichoke</sp-menu-item> | ||
<sp-menu-item>Carrot</sp-menu-item> | ||
<sp-menu-item>Potato</sp-menu-item> | ||
</sp-menu-group> | ||
<sp-menu-group> | ||
</sp-picker> | ||
``` | ||
|
||
#### Icons | ||
|
||
`<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: | |
|
||
</sp-tab-panel> | ||
</sp-tabs> | ||
|
||
#### Do not use submenus | ||
|
||
A picker menu should never contain submenus, as doing so would render it in accessible. A picker's menu role is a listbox and it's menu items are listbox options, which are not allowed to have submenus. | ||
|
Uh oh!
There was an error while loading. Please reload this page.