npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@mschreiber68/tabs

v0.0.4

Published

A set of web components to implement the tab UI pattern.

Downloads

12

Readme

Usage

Import in you Javascript bundle:

// Custom elements will automatically register themselves.
import 'mschreiber68/tabs';

// Can also import custom element classes
import { Tab, TabList, TabPanel, Tabs } from 'mschreiber68/tabs'; 
<x-tabs>
    <x-tab-list>
        <x-tab>Tab 1</x-tab>
        <x-tab selected>Tab 2</x-tab>
        <x-tab>Tab 3</x-tab>
    </x-tab-list>
    <x-tab-panel hidden>Panel 1</x-tab-panel>
    <x-tab-panel>Panel 2</x-tab-panel>
    <x-tab-panel hidden>Panel 3</x-tab-panel>
</x-tabs>

When rendering your HTML, the currently active tab should have the selected attribute. The currently inactive panels should have the hidden attribute.

The components will automatically add all ids and accessibility attributes. The above HTML will result in the below:

<x-tabs>
    <x-tab-list role="tablist">
        <x-tab id="tab-nqu4wx7plu-1" role="tab" aria-selected="false" tabindex="-1" aria-controls="tab-panel-cyvtj79027h-1">Tab 1</x-tab>
        <x-tab selected="" aria-selected="true" tabindex="0" id="tab-nqu4wx7plu-2" role="tab" aria-controls="tab-panel-cyvtj79027h-2">Tab 2</x-tab>
        <x-tab id="tab-nqu4wx7plu-3" role="tab" aria-selected="false" tabindex="-1" aria-controls="tab-panel-cyvtj79027h-3">Tab 3</x-tab>
    </x-tab-list>
    <x-tab-panel hidden="" id="tab-panel-cyvtj79027h-1" role="tabpanel" tabindex="0" aria-labelledby="tab-nqu4wx7plu-1">Panel 1</x-tab-panel>
    <x-tab-panel id="tab-panel-cyvtj79027h-2" role="tabpanel" tabindex="0" aria-labelledby="tab-nqu4wx7plu-2">Panel 2</x-tab-panel>
    <x-tab-panel hidden="" id="tab-panel-cyvtj79027h-3" role="tabpanel" tabindex="0" aria-labelledby="tab-nqu4wx7plu-3">Panel 3</x-tab-panel>
</x-tabs>

<x-tab> components must be nested somewhere within a <x-tab-list>.

<x-tab> components will be automatically associated the <x-tab-panel> at the same numerical offset. For example, the 2nd <x-tab> in the DOM will associate to the 2nd <x-tab-panel>.

Orientation

You can use the Left/Right or Up/Down keys to select tabs based on the orientation. To set the orientation, set the aria-orientation attribute on a <x-tab-list> to either vertical or horizontal:

<x-tab-list aria-orientation="vertical"></x-tab-list>

The default orientation is horizontal.

Features

  • 100% styleable, no CSS is included. Rely on the selected and hidden attributes of tabs and panels to style different states.
  • SEO-friendly
  • Accessible
  • Compatible with other frontend frameworks, or no framework. (See demo page below)
  • Automatically supports DOM updates such as tabs being added or removed. (See demo page below)
  • Supports nested tabs. (See demo page below)

Usage in other frameworks

For frameworks like Vue, you will need to call the init() method when the surrounding Vue component is mounted:

<template>
    <x-tabs ref="tabs">
        ...
    </x-tabs>
</template>
<script>
    mounted() {
        this.$refs.tabs.init();
    }
</script>

Installation

Install via NPM:

npm i @mschreiber68/tabs

Download via CDN:

<script src="https://unpkg.com/@mschreiber68/tabs@latest/dist/cdn/index.js"></script>

Demo

https://mschreiber68.github.io/tabs/demo.html