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
Side navigation allows users to locate information and features within the UI.
4
4
It can be used for either hierarchical or flat navigation, and gives the ability
@@ -7,37 +7,67 @@ prioritize content or features based on your users’ needs in a way that
7
7
maintains clear, persistent visibility. Use side navigation within the context
8
8
of larger elements and mechanisms within the app frame.
9
9
10
-
`<sp-sidenav>` elements accept both `<sp-sidenav-item>` and `<sp-sidenav-heading>` elements as children in order to construct a hierarchy of navigation elements. [`<sp-sidenav-item>`](./components/sidenav-item) elements will place themselves as a togglable child of their `<sp-sidenav>` element parent. `<sp-sidenav-heading>` elements will create visible structure by grouping their child `<sp-sidenav-item>` children under a non-interactive heading.
10
+
`<sp-sidenav>` elements accept both `<sp-sidenav-item>` and `<sp-sidenav-heading>` elements as children in order to construct a hierarchy of navigation elements. [`<sp-sidenav-item>`](/components/sidenav-item/) elements will place themselves as a togglable child of their `<sp-sidenav>` element parent. [`<sp-sidenav-heading>`](/components/sidenav-heading/) elements will create visible structure by grouping their `<sp-sidenav-item>` children under a non-interactive heading.
11
+
12
+
[View the design documentation for this component.](https://spectrum.adobe.com/page/side-navigation/)
11
13
12
14
### Usage
13
15
14
16
[](https://www.npmjs.com/package/@spectrum-web-components/sidenav)
15
17
[](https://bundlephobia.com/result?p=@spectrum-web-components/sidenav)
16
18
[](https://stackblitz.com/edit/vitejs-vite-q3w6kjxv)
17
19
18
-
```
20
+
```bash
19
21
yarn add @spectrum-web-components/sidenav
20
22
```
21
23
22
24
Import the side effectful registration of `<sp-sidenav>`, `<sp-sidenav-heading>`, or `<sp-sidenav-item>` via:
Make sure to use the right option for the context and user needs. Don’t mix behavior, styles, or variations together in a single navigation menu. Follow these guidelines:
67
+
68
+
- When navigation is simple, use the single level side navigation.
69
+
- When navigation is simple but categorical, use the single level side navigation with headers.
70
+
- When navigation is expansive, hierarchical, and/or you need progressive disclosure in the menu behavior, use the multi-level side navigation.
41
71
42
72
```html
43
73
<sp-sidenavdefaultValue="Docs">
@@ -79,38 +109,64 @@ import {
79
109
</sp-sidenav>
80
110
```
81
111
82
-
## Multi-level
112
+
</sp-tab-panel>
113
+
<sp-tabvalue="headings">With headings</sp-tab>
114
+
<sp-tab-panelvalue="headings">
115
+
116
+
Use a single level with headers side navigation when needing to group navigation items into categories. This variation has the same behavior as the single level side navigation, but it has headers that aren’t interactive. If items don’t fall into a category, place them at the top.
Use this variation when you have multiple layers of hierarchical navigation. The
85
-
headers are styled differently and possess the same interactive behavior as a
86
-
treeview; clicking the header opens and collapses the children navigation items.
137
+
Use `variant="multi-level` when you have multiple layers of hierarchical navigation.
87
138
In the instances where a top-level navigation item has no children, clicking
88
139
will send the user to the location of the item.
89
140
141
+
In multi-level side navigation, only the first-level items can have icons. Any sub-level items should always be text-only to ensure clear hierarchy. In cases where the navigation content might be user-generated, stick to text-only navigation items.
Icon and text-only navigation items can be used in combination. However, do not alternate the two to keep a clear hierarchy. When using the heading variation, an entire category should either all have icons or all be text-only.
114
170
115
171
```html
116
172
<sp-sidenav>
@@ -126,23 +182,48 @@ will send the user to the location of the item.
126
182
</sp-sidenav>
127
183
```
128
184
129
-
## Heading
185
+
</sp-tab-panel>
186
+
</sp-tabs>
187
+
188
+
### Behaviors
189
+
190
+
When an side navigation item becomes selected in `variant="multilevel"`, all of its parent items automatically expand to reveal the selection path.
191
+
192
+
### States
193
+
194
+
With the `disabled` attribute, the entire `sp-sidenav` can be removed from the tab order.
<sp-sidenav-itemvalue="Section Title 1"label="Section Title 1">
199
+
<sp-icon-starslot="icon"></sp-icon-star>
200
+
</sp-sidenav-item>
201
+
<sp-sidenav-itemvalue="Section Title 2"label="Section Title 2">
202
+
<sp-icon-starslot="icon"></sp-icon-star>
203
+
</sp-sidenav-item>
204
+
<sp-sidenav-itemvalue="Section Title 3"label="Section Title 3">
205
+
<sp-icon-starslot="icon"></sp-icon-star>
206
+
</sp-sidenav-item>
143
207
</sp-sidenav>
144
208
```
145
209
146
-
## Accessibility
210
+
### Accessibility
211
+
212
+
When the `manage-tab-index` attribute is set on an `sp-sidenav` element, it will present its `sp-sidenav-item` children with a single tab-stop. This will leave items beyond the selected item (or when there is no focusable selected item), accessible via the up and down arrow keys. Items with expanded children that aren't selected lose focus when `manage-tab-index` is active.
213
+
214
+
-`<sp-sidenav>` renders a `<nav>` tag and implicitly sets `role="navigation"`
215
+
- Optional `aria-label` is available for further identification
216
+
- Individual items use `role="listitem"` automatically
217
+
- Nested list containers (i.e. `div` tags) use `role="list"`
218
+
- Nested item containers use `aria-labelledby` referencing their parent item's `id`
219
+
-`aria-expanded="true/false"` indicates expand/collapse state for parent items
220
+
-`aria-controls` on parent items is set to the `id` of their child `role="list"` containers when expanded
221
+
-`aria-current="page"` indicates the currently selected item when it has an `href`
222
+
- When the `sp-sidenav` includes the `disabled` property, the entire component receives `tabindex="-1"`
223
+
-`aria-hidden="true"` is applied to all decorative icons
224
+
225
+
#### Keyboard interaction
147
226
148
-
When the `manage-tab-index` attribute is set on an `sp-sidenav` element then it will presents its child `sp-sidenav-item` children with a single tab-stop. This will leave items beyond the selected item, or first when there is no focusable selected item, will be accessibile via the up and down arrow keys.
227
+
-`Tab` and `Shift + Tab` moves focus into or out of the side nav
228
+
- If `manage-tab-index` is enabled, the up and down arrow keys will shift focus between all visible sidenav items
229
+
-`Enter` or `Space` selects a side nav item or toggles expansion for parent items
0 commit comments