Skip to content

Commit 2d6c12e

Browse files
committed
feat(tabs/README.md): documentation updates
1 parent 142fe7f commit 2d6c12e

File tree

1 file changed

+58
-13
lines changed

1 file changed

+58
-13
lines changed

packages/tabs/README.md

Lines changed: 58 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,74 @@
22

33
The `<sp-tabs>` displays a list of `<sp-tab>` element children as `role="tablist"`. An `<sp-tab>` element is associated with a sibling `<sp-tab-panel>` element via their `value` attribute. When an `<sp-tab>` element is `selected`, the associated `<sp-tab-panel>` will also be selected, showing that panel and hiding the others.
44

5+
[View the design documentation for this component.](https://spectrum.adobe.com/page/tabs/)
6+
57
### Usage
68

79
[![See it on NPM!](https://img.shields.io/npm/v/@spectrum-web-components/tabs?style=for-the-badge)](https://www.npmjs.com/package/@spectrum-web-components/tabs)
810
[![How big is this package in your project?](https://img.shields.io/bundlephobia/minzip/@spectrum-web-components/tabs?style=for-the-badge)](https://bundlephobia.com/result?p=@spectrum-web-components/tabs)
911
[![Try it on Stackblitz](https://img.shields.io/badge/Try%20it%20on-Stackblitz-blue?style=for-the-badge)](https://stackblitz.com/edit/vitejs-vite-3smxuwr2)
1012

11-
```
13+
```zsh
1214
yarn add @spectrum-web-components/tabs
1315
```
1416

1517
Import the side effectful registration of `<sp-tabs>`, `<sp-tab>` or `<sp-tab-panel>` via:
1618

17-
```
19+
```ts
1820
import '@spectrum-web-components/tabs/sp-tabs.js';
1921
import '@spectrum-web-components/tabs/sp-tab.js';
2022
import '@spectrum-web-components/tabs/sp-tab-panel.js';
2123
```
2224

2325
When looking to leverage the `Tabs`, `Tab`, or `TabPanel` base class as a type and/or for extension purposes, do so via:
2426

25-
```
26-
import {
27-
Tabs,
28-
Tab,
29-
TabPanel
30-
} from '@spectrum-web-components/tabs';
27+
```ts
28+
import { Tabs, Tab, TabPanel } from '@spectrum-web-components/tabs';
3129
```
3230

33-
## Sizes
31+
### Anatomy
32+
33+
- **Tabs:** The container component (`<sp-tabs>`) that manages the tab list and handles selection logic.
34+
- **Tab item:** An individual tab (`<sp-tab>`) that users can select to view different content panels.
35+
- **Tab view:** The content panel (`<sp-tab-panel>`) associated with a tab, shown when its corresponding tab is selected.
36+
- **Divider:** A visual separator between tab items, used in some variants for clarity.
37+
- **Selection indicator:** A visual highlight (such as an underline or bar) that shows which tab is currently selected.
38+
39+
### Options
40+
41+
<sp-table>
42+
<sp-table-head>
43+
<sp-table-head-cell>Property</sp-table-head-cell>
44+
<sp-table-head-cell>Values</sp-table-head-cell>
45+
<sp-table-head-cell>Default value</sp-table-head-cell>
46+
</sp-table-head>
47+
<sp-table-body>
48+
<sp-table-row>
49+
<sp-table-cell>label</sp-table-cell>
50+
<sp-table-cell>text / nothing</sp-table-cell>
51+
<sp-table-cell>–</sp-table-cell>
52+
</sp-table-row>
53+
<sp-table-row>
54+
<sp-table-cell>icon</sp-table-cell>
55+
<sp-table-cell>icon / nothing</sp-table-cell>
56+
<sp-table-cell>nothing</sp-table-cell>
57+
</sp-table-row>
58+
<sp-table-row>
59+
<sp-table-cell>is selected</sp-table-cell>
60+
<sp-table-cell>yes / no</sp-table-cell>
61+
<sp-table-cell>no</sp-table-cell>
62+
</sp-table-row>
63+
<sp-table-row>
64+
<sp-table-cell>is disabled</sp-table-cell>
65+
<sp-table-cell>yes / no</sp-table-cell>
66+
<sp-table-cell>no</sp-table-cell>
67+
</sp-table-row>
68+
</sp-table-body>
69+
</sp-table>
70+
<br/>
71+
72+
#### Sizes
3473

3574
<sp-tabs selected="m" auto label="Size Attribute Options">
3675
<sp-tab value="s">Small</sp-tab>
@@ -103,7 +142,7 @@ import {
103142
</sp-tab-panel>
104143
</sp-tabs>
105144

106-
## Horizontal Tabs
145+
#### Variants
107146

108147
An `<sp-tabs>` element will display horizontally by default. It can be modified with states like `compact`, `disabled`, and `quiet`, or with content like icons, etc.
109148

@@ -207,8 +246,6 @@ When an `<sp-tabs>` element is given the `disabled` attribute its `<sp-tab>` chi
207246
</sp-tab-panel>
208247
</sp-tabs>
209248

210-
## Vertical Tabs
211-
212249
An `<sp-tabs>` element will display horizontally by default. It can be modified with states like `compact`, `disabled`, and `quiet`, or with content like icons, etc.
213250

214251
<sp-tabs selected="compact" auto label="Horizontal Tabs variants">
@@ -311,6 +348,14 @@ When an `<sp-tabs>` element is given the `disabled` attribute its `<sp-tab>` chi
311348
</sp-tab-panel>
312349
</sp-tabs>
313350

314-
## Accessibility
351+
### Accessibility
315352

316353
When an `<sp-tabs>` has a `selected` value, the `<sp-tab>` child of that `value` will be given `[tabindex="0"]` and will receive initial focus when tabbing into the `<sp-tabs>` element. When no `selected` value is present, the first `<sp-tab>` child will be treated in this way. When focus is currently within the `<sp-tabs>` element, the left and right arrows will move that focus back and forth through the available `<sp-tab>` children.
354+
355+
#### Include a label
356+
357+
Tab items should have a label for accessibility. If a label isn’t present, it must include an icon and becomes an icon-only tab item.
358+
359+
#### Use icons only when necessary
360+
361+
Icons should only be used in a tab item when absolutely necessary: when adding essential value and having a strong association with the label. If the tab item does not have a visible label, it must still have a tooltip to disclose the label.

0 commit comments

Comments
 (0)