New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@dontgoplastic/tab-nav

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dontgoplastic/tab-nav

An accessible tab navigation component

  • 0.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

tab-nav

An easy-to-use, zero-dependency, and accessible tab navigation component

Demo

How to use

Create a list with corresponding content targets:

<ul id="repo-nav">
  <li data-tab-content-id="all">All</li>
  <li data-tab-content-id="public">Public</li>
  <li data-tab-content-id="private">Private</li>
</ul>

<section id="all"> ... </section>
<section id="public"> ... </section>
<section id="private"> ... </section>

Kick off a TabNav:

new TabNav('#repo-nav');

Instances can be configured with a few options:

new TabNav('#repo-nav', {
  activeClass: 'active',
  onChange: (tabElement, contentElement) => {
    // ...
  }
});
NameDefault ValueDescription
activeClass'active'Class applied to expanded tabs
onChangenullCallback for when expaned tabs change. Provides the tab and revealed content target elements as arguments

Styles

Bring your own!

What it does

  • role attribute values tablist, tab, and tabpanel will be added to the list, list items, and content targets.
  • tabindex="0" added to the expanded tab and all content targets.
  • With a tab focused, or will focus the previous tab, or the next.
  • Tabs will be expanded on mouse click. Focused tabs will can be expanded by pressing either Enter or Space.
  • A tab with the activeClass (or the first tab if not present) will be auto-expanded.
  • All non-expanded content targets will be hidden via display: none;.
  • If ids aren't already present, unique ids are auto-assigned to all tabs and content targets to facilitate aria-labelledby and aria-controls hook-up.

Keywords

FAQs

Package last updated on 26 Jan 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc