GitHub
Core
Glass
Brutal
Humanist

Bar Tabs

Bar Tabs provide navigation with an animated sliding indicator showing the selected tab. Available in horizontal and vertical orientations.

Horizontal Bar Tabs Playground

Horizontal Bar Tabs Playground
Preview
Code
Controls
Icons:
Bottom Line:
Badges:

Vertical Bar Tabs Playground

Vertical Bar Tabs Playground
Preview
Code
Controls
Icons:
Left Line:
Badges:

Installation

You can add the bar tabs component to your project manually:

1

Install the following dependencies:

npm install class-variance-authority clsx @phosphor-icons/react @react-aria/focus
2

Copy and paste the following code into your project.

Loading source code...
3

Update the import paths to match your project setup.

Update the import aliases (e.g. @/components, @/utils) in the copied files to match your project's path configuration.

Basic Usage

import { useState } from 'react';
import { HorizontalBarTabs } from '@versaui/ui/components/BarTab';
import { HouseIcon, CompassIcon, StackIcon } from '@phosphor-icons/react';
function Navigation() {
  const [selectedId, setSelectedId] = useState('home');
  const tabs = [
    { id: 'home', label: 'Home', icon: <HouseIcon size={20} /> },
    { id: 'explore', label: 'Explore', icon: <CompassIcon size={20} /> },
    { id: 'library', label: 'Library', icon: <StackIcon size={20} />, badge: 5 },
  ];
  return (
    <HorizontalBarTabs
      items={tabs}
      selectedId={selectedId}
      onChange={setSelectedId}
    />
  );
}

TabItem Interface

interface TabItem {
  id: string;        // Unique identifier
  label: string;     // Tab label
  icon?: ReactNode;  // Optional leading icon
  badge?: number;    // Optional badge count
  disabled?: boolean; // Disabled state
}

Accessibility

  • Uses role="tablist" and role="tab" with proper aria-selected and aria-disabled
  • Full keyboard navigation:
    • ArrowLeft/Right for horizontal tabs
    • ArrowUp/Down for vertical tabs
    • Home/End to jump to first/last tab
  • Focus ring visible on keyboard navigation

BarTab Props

PropTypeDefaultDescription
orientation'horizontal' | 'vertical''horizontal'Tab orientation.
state'default' | 'hovered' | 'selected' | 'disabled''default'Visual state for demos.
showIconbooleantrueShow leading icon.
leadingIconReactNodeCirclesThreeCustom leading icon.
showBadgebooleanfalseShow badge.
badgeCountnumber0Badge count value.
childrenReactNodeTab label.
selectedbooleanControlled selected state.
disabledbooleanfalseDisabled state.
hideBarIndicatorbooleanfalseHide bar (when parent handles it).
onClick() => voidClick handler.
classNamestring''Additional CSS classes.

HorizontalBarTabs Props

PropTypeDefaultDescription
itemsTabItem[]Array of tab items.
selectedIdstringCurrently selected tab ID.
onChange(id: string) => voidSelection change handler.
showIconsbooleantrueShow icons if provided in items.
showBottomLinebooleantrueShow bottom border line.
classNamestring''Additional CSS classes.

VerticalBarTabs Props

PropTypeDefaultDescription
itemsTabItem[]Array of tab items.
selectedIdstringCurrently selected tab ID.
onChange(id: string) => voidSelection change handler.
showIconsbooleantrueShow icons if provided in items.
showLeftLinebooleantrueShow left border line.
widthstring | number160Container width.
classNamestring''Additional CSS classes.

On this page