Skip to content

Commit dda064c

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

File tree

1 file changed

+52
-11
lines changed

1 file changed

+52
-11
lines changed

packages/tabs/README.md

Lines changed: 52 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,68 @@ The `<sp-tabs>` displays a list of `<sp-tab>` element children as `role="tablist
88
[![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)
99
[![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)
1010

11-
```
11+
```zsh
1212
yarn add @spectrum-web-components/tabs
1313
```
1414

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

17-
```
17+
```ts
1818
import '@spectrum-web-components/tabs/sp-tabs.js';
1919
import '@spectrum-web-components/tabs/sp-tab.js';
2020
import '@spectrum-web-components/tabs/sp-tab-panel.js';
2121
```
2222

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

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

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

212251
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.
213252

@@ -314,3 +353,5 @@ When an `<sp-tabs>` element is given the `disabled` attribute its `<sp-tab>` chi
314353
## Accessibility
315354

316355
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.
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. 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)