Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@accessible-web-components/tabs

danielmatthew10MIT0.2.0

An accessible tabs web component

web components, lit-element, accessibility

readme

Tabs

Published on npm

Demo

https://v505e.csb.app/

Browser Support

Browser Assistive Technology
: macOS :
Safari 13.0.4 ✅ : VoiceOver ✅
Firefox 79 ✅ :
Chrome ✅ :
Edge ✅ :

Usage

import { AwcTabs, AwcTab, AwcPanel } from '@accessible-web-components/tabs';

window.customElements.define('awc-tabs', AwcTabs);
window.customElements.define('awc-tab', AwcTab);
window.customElements.define('awc-panel', AwcPanel);
<awc-tabs>
  <awc-tab role="heading" slot="tab" id="my-first-tab" >Tab 1</awc-tab>
  <awc-panel role="region" slot="panel" id="my-first-panel">
    <h2>My first tab</h2>
    <p>Here is some text…</p>
    <ul>
      <li>…and a list</p>
    </ul>

    <button type="button">I am a focusable element within the tab</button>
  </awc-panel>

  <awc-tab role="heading" slot="tab">Tab 2</awc-tab>
  <awc-panel role="region" slot="panel">Content 2</awc-panel>

  <awc-tab role="heading" slot="tab">Tab 3</awc-tab>
  <awc-panel role="region" slot="panel">Content 3</awc-panel>
</awc-tabs>
  • The roles of heading and region are replaced by tab and tabpanel respectively at runtime. They provide some level of redundancy to the new elements should there be a runtime error.

Requirements

Per https://www.w3.org/TR/wai-aria-practices-1.2/#tabpanel:

Keyboard

  • Focus on active tab element
  • Left arrow: previous
  • Right arrow: next
  • Space/Enter: activate
  • Home: first
  • End: last

Roles

  • Container has a role of tablist
  • tablist should be labelledby active tab
  • Each element representing a tab has the role tab and is contained within the tablist
  • Each element representing tab content has the role of tabpanel

changelog

Change Log

All notable changes to this project will be documented in this file. See Conventional Commits for commit guidelines.

0.2.0 (2020-07-22)

  • feat(tabs): add support for orientation (#24) (3965132), closes #24

0.1.7 (2020-07-18)

0.1.6 (2020-07-18)

  • fix(tabs): revert changes to panel/tab counters (253453c)
  • fix(tabs): tablist is labelled by selected tab (c2d2a3b)
  • chore: sort versioning (797cb75)
  • chore(deps): bump lodash from 4.17.15 to 4.17.19 (#20) (a87efb8), closes #20
  • chore(tabs): add test coverage (#22) (ad9e297), closes #22
  • chore(tabs): update es-dev-server script (f314cca)

0.0.0-alpha.5 (2020-07-15)

  • fix(tabs): remove UP/DOWN handling (214ac42), closes #18
  • chore: use main branch (e11c483)
  • chore(tabs): add badge to readme (ff5c9c3)
  • chore(tabs): update keywords (0827f4d)

0.0.0-alpha.4 (2020-07-14)

  • chore(deps): bump npm from 6.14.5 to 6.14.6 in /components/tabs (#15) (625257a), closes #15
  • chore(tabs): add usage instructions to readme (1dcabc7)
  • chore(tabs): convert todos into issues (1bc4ef7)

0.0.0-alpha.3 (2020-07-12)

  • chore(tabs): add publishConfig (b13a07c)

0.0.0-alpha.2 (2020-07-12)

  • fix(tabs): use correct naming scheme (0cbf049)
  • chore: add npm-run-all (51c0ff4)

0.0.0-alpha.1 (2020-07-12)

  • chore: update privacy and versions (cde0868)
  • chore: update scripts (af5afba)
  • chore(lerna): bootstrap and hoist dependencies (44900e0)
  • chore(lerna): rename components directory (b0b283a)
  • chore(tabs): install es-dev-server (7319b4a)
  • refactor: the linter abides (eae6715)