An accessible tab container element with keyboard support.
Перейти к файлу
Kristján Oddsson 267c627698
3.0.5
2019-08-14 09:14:40 +01:00
examples Fix script comment for cmd + / 2019-04-04 19:23:44 -04:00
test add dispatching of `tab-container-change` event 2019-06-10 11:52:18 +01:00
.babelrc update babel depenecies and use babel-preset-github 2019-02-20 15:57:12 +00:00
.eslintrc.json extend github flow eslint config 2019-02-20 16:04:14 +00:00
.flowconfig Add Flow toolchain 2018-06-27 15:09:29 -06:00
.gitignore Add set up code 2018-06-25 16:49:41 -04:00
.travis.yml Add set up code 2018-06-25 16:49:41 -04:00
LICENSE Add set up code 2018-06-25 16:49:41 -04:00
README.md reorder events in documentation 2019-06-10 18:41:41 +01:00
index.d.ts add typescript definition file 2019-07-01 18:21:18 +01:00
index.js default export the element 💀 2019-06-12 12:14:47 +01:00
index.js.flow remove `selectTab(..)` from the public API 2019-05-14 10:05:31 +01:00
package-lock.json 3.0.5 2019-08-14 09:14:40 +01:00
package.json 3.0.5 2019-08-14 09:14:40 +01:00
prettier.config.js extend github flow eslint config 2019-02-20 16:04:14 +00:00

README.md

<tab-container> element

A accessible tab container element with keyboard support. Follows the ARIA best practices guide on tabs.

Installation

$ npm install @github/tab-container-element

Usage

import '@github/tab-container-element'
<tab-container>
  <div role="tablist">
    <button type="button" role="tab" aria-selected="true">Tab one</button>
    <button type="button" role="tab">Tab two</button>
    <button type="button" role="tab">Tab three</button>
  </div>
  <div role="tabpanel">
    Panel 1
  </div>
  <div role="tabpanel" hidden>
    Panel 2
  </div>
  <div role="tabpanel" hidden>
    Panel 3
  </div>
</tab-container>

Events

  • tab-container-change (bubbles, cancelable): fired on <tab-container> before a new tab is selected and visibility is updated. event.detail.relatedTarget is the tab panel that will be selected if the event isn't cancelled.
  • tab-container-changed (bubbles): fired on <tab-container> after a new tab is selected and visibility is updated. event.detail.relatedTarget is the newly visible tab panel.

Browser support

Browsers without native custom element support require a polyfill.

  • Chrome
  • Firefox
  • Safari
  • Microsoft Edge

Development

npm install
npm test

License

Distributed under the MIT license. See LICENSE for details.