Tabs
Switch between layered content panels — settings pages, dashboards, and code previews — with the neobrutalist borders-and-shadows treatment.
import {
Card,
CardContent,Tabs organize layered panels of content behind a row of triggers — one panel visible at a time, no navigation. Built on the Base UI Tabs component and styled to the neobrutalist recipe: thick borders, hard shadows, and bold type.
Reach for it when:
- Settings pages — Account / Password / Notifications on one screen, state preserved when switching.
- Dashboard views — swap between Overview, Analytics, and Reports without a route change.
- Code + preview panes — the docs-site staple: Preview / Code toggles and per-package-manager install commands.
Installation#
pnpm dlx shadcn@latest add https://neobrutalism.com/r/base/tabs.jsonnpx shadcn@latest add https://neobrutalism.com/r/base/tabs.jsonyarn dlx shadcn@latest add https://neobrutalism.com/r/base/tabs.jsonbunx --bun shadcn@latest add https://neobrutalism.com/r/base/tabs.json
Install the following dependencies:
pnpm add @base-ui/reactnpm install @base-ui/reactyarn add @base-ui/reactbun add @base-ui/react
Copy and paste the following code into your project.
"use client"
import * as React from "react"
import { cva, type VariantProps } from "class-variance-authority"
import { Tabs as TabsPrimitive } from "radix-ui"
import { cn } from "@/lib/utils"
function Tabs({
className,
orientation = "horizontal",
...props
}: React.ComponentProps<typeof TabsPrimitive.Root>) {
return (
<TabsPrimitive.Root
data-slot="tabs"
data-orientation={orientation}
className={cn(
"group/tabs flex gap-2 data-horizontal:flex-col",
className
)}
{...props}
/>
)
}
const tabsListVariants = cva(
"group/tabs-list inline-flex w-fit items-center justify-center rounded p-1 text-muted-foreground group-data-horizontal/tabs:h-11 group-data-vertical/tabs:h-fit group-data-vertical/tabs:flex-col data-[variant=line]:rounded-none",
{
variants: {
variant: {
default: "border-2 bg-card shadow-sm",
line: "gap-1 bg-transparent",
},
},
defaultVariants: {
variant: "default",
},
}
)
function TabsList({
className,
variant = "default",
...props
}: React.ComponentProps<typeof TabsPrimitive.List> &
VariantProps<typeof tabsListVariants>) {
return (
<TabsPrimitive.List
data-slot="tabs-list"
data-variant={variant}
className={cn(tabsListVariants({ variant }), className)}
{...props}
/>
)
}
function TabsTrigger({
className,
...props
}: React.ComponentProps<typeof TabsPrimitive.Trigger>) {
return (
<TabsPrimitive.Trigger
data-slot="tabs-trigger"
className={cn(
"relative inline-flex h-[calc(100%-1px)] flex-1 cursor-pointer items-center justify-center gap-1.5 rounded border-2 border-transparent px-4 py-2 text-sm font-head font-medium whitespace-nowrap text-foreground/60 transition-all group-data-vertical/tabs:w-full group-data-vertical/tabs:justify-start hover:text-foreground focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary disabled:pointer-events-none disabled:opacity-50 has-data-[icon=inline-end]:pr-1 has-data-[icon=inline-start]:pl-1 group-data-[variant=default]/tabs-list:data-active:border-border group-data-[variant=default]/tabs-list:data-active:shadow-sm group-data-[variant=line]/tabs-list:data-active:shadow-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
"group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-active:bg-transparent",
"data-active:bg-primary data-active:text-primary-foreground group-data-[variant=line]/tabs-list:data-active:text-foreground",
"after:absolute after:bg-foreground after:opacity-0 after:transition-opacity group-data-horizontal/tabs:after:inset-x-0 group-data-horizontal/tabs:after:bottom-[-5px] group-data-horizontal/tabs:after:h-1 group-data-vertical/tabs:after:inset-y-0 group-data-vertical/tabs:after:-right-1 group-data-vertical/tabs:after:w-1 group-data-[variant=line]/tabs-list:data-active:after:opacity-100",
className
)}
{...props}
/>
)
}
function TabsContent({
className,
...props
}: React.ComponentProps<typeof TabsPrimitive.Content>) {
return (
<TabsPrimitive.Content
data-slot="tabs-content"
className={cn("flex-1 text-sm outline-none", className)}
{...props}
/>
)
}
export { Tabs, TabsList, TabsTrigger, TabsContent, tabsListVariants }
Update the import paths to match your project setup.
Usage#
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"<Tabs defaultValue="account" className="w-[400px]">
<TabsList>
<TabsTrigger value="account">Account</TabsTrigger>
<TabsTrigger value="password">Password</TabsTrigger>
</TabsList>
<TabsContent value="account">Make changes to your account here.</TabsContent>
<TabsContent value="password">Change your password here.</TabsContent>
</Tabs>Composition#
Use the following composition to build Tabs:
Tabs
├── TabsList
│ ├── TabsTrigger
│ └── TabsTrigger
├── TabsContent
└── TabsContentExamples#
Line#
Use the variant="line" prop on TabsList for a line style.
import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs"
export function TabsLine() {Vertical#
Use orientation="vertical" for vertical tabs.
import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs"
export function TabsVertical() {Disabled#
import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs"
export function TabsDisabled() {Icons#
import { AppWindowIcon, CodeIcon } from "lucide-react"
import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs"RTL#
To enable RTL support in Neobrutalism.com, see the RTL configuration guide.
"use client"
import * as React from "react"Accessibility#
Tabs follow the WAI-ARIA Tabs pattern: the list renders role="tablist", each trigger is a role="tab" button with aria-selected and aria-controls, and each panel is a role="tabpanel" labelled by its trigger. Only the active trigger is in the tab order — arrow keys handle the rest (roving tabindex). By default, focusing a trigger also activates it; set activateOnFocus={false} on TabsList to require an explicit Space/Enter.
Keyboard interactions:
| Key | Action |
|---|---|
Tab | Move focus to the active trigger, then into the active panel |
ArrowRight / ArrowLeft | Move focus to the next / previous trigger (horizontal orientation) |
ArrowDown / ArrowUp | Move focus to the next / previous trigger (vertical orientation) |
Home / End | Jump to the first / last trigger |
Space / Enter | Activate the focused trigger (needed only with manual activation) |
API Reference#
See the Base UI Tabs documentation.