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

@shadowfax-tech/tab

v0.1.4

Published

Accessible, flexible tabs component with useTabs hook for SFX UI

Downloads

89

Readme

@shadowfax-tech/tab

A fully accessible, flexible tabs component with a powerful useTabs() hook for managing tab state. Built with the SFX UI theme system.

Features

  • Accessible: Full ARIA support and keyboard navigation
  • 🔧 Flexible Hook: useTabs() hook for complete tab state management
  • 🎯 TypeScript: Fully typed with comprehensive interfaces
  • 📦 Dynamic: Add, remove, and update tabs programmatically
  • 🎨 Theme Integration: Uses SFX UI Theme design tokens
  • 🎛️ Variants: Multiple sizes, full-width mode, badges, icons
  • 🚀 Performance: Optimized with React best practices

Installation

npm install @shadowfax-tech/tab
# or
yarn add @shadowfax-tech/tab

Quick Start

import { Tabs, useTabs } from '@shadowfax-tech/tab';
import '@shadowfax-tech/tab/styles';

function MyComponent() {
  const { tabs, activeTab, setActiveTab } = useTabs({
    initialTab: 'tab-1',
    tabs: [
      { id: 'tab-1', label: 'Tab 1' },
      { id: 'tab-2', label: 'Tab 2' },
      { id: 'tab-3', label: 'Tab 3' },
    ],
  });

  return (
    <div>
      <Tabs
        tabs={tabs}
        activeTab={activeTab}
        onTabChange={setActiveTab}
      />
      
      <div style={{ padding: '24px' }}>
        {activeTab === 'tab-1' && <div>Tab 1 Content</div>}
        {activeTab === 'tab-2' && <div>Tab 2 Content</div>}
        {activeTab === 'tab-3' && <div>Tab 3 Content</div>}
      </div>
    </div>
  );
}

Tabs with Badges

const { tabs, activeTab, setActiveTab } = useTabs({
  initialTab: 'pending',
  tabs: [
    { id: 'pending', label: 'Pending', badge: 12 },
    { id: 'approved', label: 'Approved', badge: 8 },
    { id: 'rejected', label: 'Rejected', badge: 3 },
  ],
});

<Tabs tabs={tabs} activeTab={activeTab} onTabChange={setActiveTab} />

Tabs with Icons

import { CalendarIcon, ChartIcon } from './icons';

const { tabs, activeTab, setActiveTab } = useTabs({
  initialTab: 'dashboard',
  tabs: [
    { id: 'dashboard', label: 'Dashboard', icon: <ChartIcon /> },
    { id: 'calendar', label: 'Calendar', icon: <CalendarIcon /> },
  ],
});

<Tabs tabs={tabs} activeTab={activeTab} onTabChange={setActiveTab} />

Dynamic Tab Management

const { 
  tabs, 
  activeTab, 
  setActiveTab, 
  addTab, 
  removeTab, 
  updateTab 
} = useTabs({
  initialTab: 'tab-1',
  tabs: [{ id: 'tab-1', label: 'Tab 1' }],
});

// Add a new tab
addTab({ id: 'tab-2', label: 'Tab 2' });

// Remove a tab
removeTab('tab-1');

// Update tab badge
updateTab('tab-2', { badge: 10 });

API Reference

useTabs Hook

const { 
  tabs,           // Array of tab items
  activeTab,      // Currently active tab ID
  setActiveTab,   // Change active tab
  getActiveTab,   // Get active tab object
  addTab,         // Add a new tab
  removeTab,      // Remove a tab
  updateTab,      // Update a tab
  isTabActive     // Check if tab is active
} = useTabs({
  initialTab: 'tab-1',
  tabs: [...],
  onTabChange: (tabId) => { /* callback */ }
});

Tabs Component Props

| Prop | Type | Default | Description | |------|------|---------|-------------| | tabs | Tab[] | required | Array of tab items | | activeTab | string | required | Currently active tab ID | | onTabChange | (tabId: string) => void | required | Callback when tab is clicked | | className | string | - | Additional CSS class | | size | 'small' \| 'medium' \| 'large' | 'medium' | Size variant | | fullWidth | boolean | false | Full width mode |

Tab Interface

interface Tab {
  id: string;              // Unique identifier
  label: string;           // Display text
  badge?: number | string; // Optional badge
  disabled?: boolean;      // Disable the tab
  icon?: React.ReactNode;  // Optional icon
}

Different Sizes

<Tabs size="small" {...props} />   {/* Small tabs */}
<Tabs size="medium" {...props} />  {/* Default size */}
<Tabs size="large" {...props} />   {/* Large tabs */}

Full Width Tabs

<Tabs fullWidth tabs={tabs} activeTab={activeTab} onTabChange={setActiveTab} />

Disabled Tabs

const { tabs, activeTab, setActiveTab } = useTabs({
  initialTab: 'active',
  tabs: [
    { id: 'active', label: 'Active' },
    { id: 'disabled', label: 'Disabled', disabled: true },
    { id: 'enabled', label: 'Enabled' },
  ],
});

Accessibility

The tab component follows WAI-ARIA best practices:

  • ✅ Proper role="tablist" and role="tab" attributes
  • aria-selected to indicate active tab
  • aria-disabled for disabled tabs
  • ✅ Keyboard navigation support (Enter/Space)
  • ✅ Focus management with tabIndex
  • ✅ Semantic HTML with proper button elements

License

MIT

Links