From 2d6c12e4afc30228986343426833fc6d447cfed6 Mon Sep 17 00:00:00 2001 From: Cory Dransfeldt Date: Wed, 25 Jun 2025 12:38:17 -0700 Subject: [PATCH] feat(tabs/README.md): documentation updates --- packages/tabs/README.md | 71 +++++++++++++++++++++++++++++++++-------- 1 file changed, 58 insertions(+), 13 deletions(-) diff --git a/packages/tabs/README.md b/packages/tabs/README.md index 640fc3f3b29..8da8e3ad7b0 100644 --- a/packages/tabs/README.md +++ b/packages/tabs/README.md @@ -2,19 +2,21 @@ The `` displays a list of `` element children as `role="tablist"`. An `` element is associated with a sibling `` element via their `value` attribute. When an `` element is `selected`, the associated `` will also be selected, showing that panel and hiding the others. +[View the design documentation for this component.](https://spectrum.adobe.com/page/tabs/) + ### Usage [![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) [![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) [![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) -``` +```zsh yarn add @spectrum-web-components/tabs ``` Import the side effectful registration of ``, `` or `` via: -``` +```ts import '@spectrum-web-components/tabs/sp-tabs.js'; import '@spectrum-web-components/tabs/sp-tab.js'; import '@spectrum-web-components/tabs/sp-tab-panel.js'; @@ -22,15 +24,52 @@ import '@spectrum-web-components/tabs/sp-tab-panel.js'; When looking to leverage the `Tabs`, `Tab`, or `TabPanel` base class as a type and/or for extension purposes, do so via: -``` -import { - Tabs, - Tab, - TabPanel -} from '@spectrum-web-components/tabs'; +```ts +import { Tabs, Tab, TabPanel } from '@spectrum-web-components/tabs'; ``` -## Sizes +### Anatomy + +- **Tabs:** The container component (``) that manages the tab list and handles selection logic. +- **Tab item:** An individual tab (``) that users can select to view different content panels. +- **Tab view:** The content panel (``) associated with a tab, shown when its corresponding tab is selected. +- **Divider:** A visual separator between tab items, used in some variants for clarity. +- **Selection indicator:** A visual highlight (such as an underline or bar) that shows which tab is currently selected. + +### Options + + + + Property + Values + Default value + + + + label + text / nothing + + + + icon + icon / nothing + nothing + + + is selected + yes / no + no + + + is disabled + yes / no + no + + + +
+ +#### Sizes Small @@ -103,7 +142,7 @@ import {
-## Horizontal Tabs +#### Variants An `` element will display horizontally by default. It can be modified with states like `compact`, `disabled`, and `quiet`, or with content like icons, etc. @@ -207,8 +246,6 @@ When an `` element is given the `disabled` attribute its `` chi
-## Vertical Tabs - An `` element will display horizontally by default. It can be modified with states like `compact`, `disabled`, and `quiet`, or with content like icons, etc. @@ -311,6 +348,14 @@ When an `` element is given the `disabled` attribute its `` chi
-## Accessibility +### Accessibility When an `` has a `selected` value, the `` child of that `value` will be given `[tabindex="0"]` and will receive initial focus when tabbing into the `` element. When no `selected` value is present, the first `` child will be treated in this way. When focus is currently within the `` element, the left and right arrows will move that focus back and forth through the available `` children. + +#### Include a label + +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. + +#### Use icons only when necessary + +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.