Skip to content
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions packages/picker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ import { Picker } from '@spectrum-web-components/picker';

### Anatomy

A picker includes a label and a menu..

#### 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.
Expand Down Expand Up @@ -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.
Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎶 I loveeeeee this so much


```html demo
<sp-picker>
Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.
Expand Down Expand Up @@ -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.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A more detailed explanation and reminder not to use submenus in a picker.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reinforcement 🤌 TY

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be inaccessible? ✨

Loading