Animated tab component with smooth sliding background transition. Perfect for filtering, view switching, and navigation within a section.
size="small"(no size prop)size="large"mode="text"mode="icon"mode="both"equalWidth={false}equalWidth={true}equalWidth={true}equalWidth={true}fullWidth={false}fullWidth={true}Filter content by status
{ options: "3 items" }Select priority level
{ options: "3 items" }Two-option switching
{ options: "2 items" }Four or more options
{ options: "4+ items" }Override width with className
{ className: "w-full" }Short labels for tight spaces
{ compact: true }Icon-only tabs for toolbars
{ mode: ""icon"" }Larger icon-only tabs
{ mode: ""icon"", size: ""large"" }Icon and text combined
{ mode: ""both"" }import { useState } from "react";
import { SlidingTabs } from "@/components/ui/sliding-tabs";
import { LayoutGrid, List, AlignLeft, AlignCenter, AlignRight } from "lucide-react";
// Basic usage (text mode - default)
const [value, setValue] = useState("drafts");
<SlidingTabs
value={value}
onValueChange={setValue}
options={[
{ value: "drafts", label: "Drafts" },
{ value: "schedule", label: "Schedule" },
{ value: "posted", label: "Posted" },
]}
/>
// Icon mode
<SlidingTabs
value={alignment}
onValueChange={setAlignment}
mode="icon"
options={[
{ value: "left", label: "Left", icon: <AlignLeft /> },
{ value: "center", label: "Center", icon: <AlignCenter /> },
{ value: "right", label: "Right", icon: <AlignRight /> },
]}
/>
// Both mode (icon + text)
<SlidingTabs
value={viewType}
onValueChange={setViewType}
mode="both"
options={[
{ value: "grid", label: "Grid", icon: <LayoutGrid /> },
{ value: "list", label: "List", icon: <List /> },
]}
/>
// Different sizes
<SlidingTabs size="small" ... /> // 28px height
<SlidingTabs size="default" ... /> // 32px height (default)
<SlidingTabs size="large" ... /> // 40px height
// Equal width distribution (tabs are equal sized)
<SlidingTabs
value={value}
onValueChange={setValue}
equalWidth={true}
options={[
{ value: "drafts", label: "Drafts" },
{ value: "schedule", label: "Schedule" },
{ value: "posted", label: "Posted" },
]}
/>
// Full width (container fills parent, tabs keep natural sizing)
<SlidingTabs
value={value}
onValueChange={setValue}
fullWidth={true}
options={[
{ value: "all", label: "All" },
{ value: "drafts", label: "Drafts" },
{ value: "schedule", label: "Schedule" },
{ value: "posted", label: "Posted" },
]}
/>This is a controlled component that requires both value and onValueChange props.