Last updated 4 months ago by 19h47 .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @19h47/tabs 
SYNC missed versions from official npm registry.


Tabulation partout, tabulation nulle part


yarn add @19h47/tabs


import Tabs from '@19h47/tabs';

const $element = document.querySelector('.js-tabs');
const tabs = new Tabs($element);


The element that serves as a container for the set of tabs. The role="tablist" attribute is required.
The aria-label="" attribute provides a label that describes the purpose of the set of tabs.

<ul role="tablist" aria-label="navigation">
		<button type="button" class="is-active" role="tab" aria-selected="true" aria-controls="home-tab" id="home">Home</button>
		<button type="button" role="tab" aria-selected="false" aria-controls="project-tab" id="project" tabindex="-1">Project</button>
		<button type="button" role="tab" aria-selected="false" aria-controls="contact-tab" id="contact" tabindex="-1" data-deletable="">Contact</button>

You can change the tablist orientation with the attribute aria-orientation on the tablist element:

<ul role="tablist" aria-orientation="vertical"></ul>


An element in the tab list that serves as a label for one of the tab panels and can be activated to display that panel.

<button type="button" role="tab" aria-selected="false" aria-controls="foo-tab" id="foo" tabindex="-1">

The role="tab" attribute is required.

The aria-controls="foo-tab" refers to the id of the tabpanel element associated with the tab.

Since an HTML button element is used for the tab, it is not necessary to set tabindex="0" on the selected (active) tab element.

Is the tabulation deletable ? You can set up this option by adding the data-deletable attribute on button.

To active the button on first load, add a is-active class to the button, remove the tabindex attribute and switch to true the aria-selected attribute.


The element that contains the content associated with a tab.

<section tabindex="0" role="tabpanel" aria-labelledby="foo" id="foo-tab">
	<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Nihil hic, vero. Fugiat voluptas ex consequatur hic nemo officia iure placeat non, pariatur, dolore natus nobis, tempore dolores dicta nisi inventore.</p>

To active panel on first load, add a ìs-active class to it.

Keyboard support

Key Function
  • When focus moves into the tab list, places focus on the active tab element
  • When the tab list contains the focus, moves focus to the next element in the tab sequence, which is the tabpanel element.
When a tab has focus, activates the tab, causing its associated panel to be displayed.
Right Arrow When a tab has focus:
  • Moves focus to the next tab.
  • If focus is on the last tab, moves focus to the first tab.
Left Arrow When a tab has focus:
  • Moves focus to the previous tab.
  • If focus is on the first tab, moves focus to the last tab.
fn + left arrow
When a tab has focus, moves focus to the first tab.
fn + right arrow
When a tab has focus, moves focus to the last tab.
Delete When focus is on the Contact tab, removes the tab from the tab list and places focus on the previous tab.


An example is located right here, see sources.


Current Tags

  • 4.1.4                                ...           latest (4 months ago)

2 Versions

  • 4.1.4                                ...           4 months ago
  • 4.1.3                                ...           4 months ago
Maintainers (1)
Today 0
This Week 2
This Month 6
Last Day 0
Last Week 0
Last Month 4
Dependencies (2)
Dependents (0)

Copyright 2014 - 2016 © taobao.org |