Tabs

Accessible tabs with icon support, sliding indicator, and optional content panels. Keyboard navigable.

Component

Profile content goes here.

Installation

pnpm dlx shadcn@latest add "https://pulkitxm.com/components/tabs.json"

Usage

Import

Add the Tabs import.

import { Tabs } from "@/components/tabs";

Use

Pass tabs array with id, label, icon.

<Tabs
  tabs={[{ id: "tab1", label: "Tab 1", icon: User }]}
/>;

Guidelines

  • Each tab requires id, label, and icon (LucideIcon from lucide-react).
  • showContent=true renders tab.content in panels below the tab bar.
  • Use onTabChange to react to tab selection (e.g. scroll, fetch data).
  • Keyboard: ArrowLeft and ArrowRight navigate between tabs.

Props

All props are optional unless marked required. Use these to customize every aspect of the component.

PropTypeDefaultDescription
tabsTab[]Array of tab objects with id, label, icon, and optional content.
defaultSelectedstringInitially selected tab id.
selectedstringControlled selected tab id.
onTabChange(id: string) => voidCallback when tab changes.
classNamestring""Additional CSS classes for the container.
showContentbooleanfalseWhether to render tab content panels.
contentClassNamestring""Classes for the content container.

Examples

With content

Three tabs with content panels.

Profile content goes here.
import { Tabs } from "@/components/tabs";
import { FileText, Settings, User } from "lucide-react";

<Tabs
  tabs={[
    {
      id: "profile",
      label: "Profile",
      icon: User,
      content: <p>Profile content</p>,
    },
    {
      id: "docs",
      label: "Docs",
      icon: FileText,
      content: <p>Docs content</p>,
    },
    {
      id: "settings",
      label: "Settings",
      icon: Settings,
      content: <p>Settings content</p>,
    },
  ]}
  defaultSelected="profile"
  showContent={true}
/>;

Navigation only

Tabs without content, use onTabChange for navigation.

Profile content goes here.
import { Tabs } from "@/components/tabs";
import { Code2, Layers } from "lucide-react";

<Tabs
  tabs={[
    { id: "code", label: "Code", icon: Code2 },
    { id: "preview", label: "Preview", icon: Layers },
  ]}
  defaultSelected="code"
  onTabChange={(id) => console.log(id)}
/>;

Last updated on Mar 10

Made with ❤️ by Pulkit & Cursor :)

© 2026 Pulkit. All rights reserved

DMCA Verified

Last updated: