Command Palette

Search for a command to run...

Docs
Sliding Tabs

Sliding Tabs

Tab component with sliding gradient indicator and keyboard navigation support

Loading...

Installation

Usage

import SlidingTabs from "@/components/ruixen/sliding-tabs";
 
const tabItems = [
  { key: 0, label: "Overview", panel: "Overview content" },
  { key: 1, label: "Activity", panel: "Activity content" },
  { key: 2, label: "Settings", panel: "Settings content" },
];
 
export default function App() {
  return (
    <SlidingTabs
      items={tabItems}
      defaultIndex={0}
      onChange={(index) => console.log(`Tab ${index} selected`)}
      hoverScale={1.4}
    />
  );
}

Props

PropTypeDefaultDescription
itemsTabItem[]DefaultArray of tab items
defaultIndexnumber0Default active tab index
onChangefunction-Callback when tab changes
classNamestring""Additional CSS classes

Features

  • Sliding Indicator: Gradient background that slides between tabs
  • Glow Effect: Blurred glow behind the sliding indicator
  • Keyboard Navigation: Arrow keys, Home, End support
  • Mix Blend Mode: Uses mix-blend-mode for visual effects
  • Responsive: Automatically measures tab positions

Keyboard Navigation

  • Arrow Right: Move to next tab
  • Arrow Left: Move to previous tab
  • Home: Move to first tab
  • End: Move to last tab

Types

interface TabItem {
  key: string | number;
  label: React.ReactNode;
  panel?: React.ReactNode;
}