GooseUI

Components

Tabs


Tabs organize related content into selectable panels. Native radio inputs handle selection and keyboard navigation. The active tab's pill glides to the new tab and takes its width, and the new panel fades in. There is a vertical layout and an underline variant.

Browser support

Anchor positioning

The pill and the underline are anchored to the active tab and glide to the next one. Without support the active tab paints itself and the switch is instant.

Your browser:
@starting-style

A new panel fades in from transparent with a 6 pixel shift.

Your browser:
:has()

The selector styles radio input states.

Your browser:

Preview

Installation

npx shadcn@latest add @gooseui/tabs
pnpm dlx shadcn@latest add @gooseui/tabs
yarn dlx shadcn@latest add @gooseui/tabs
bunx --bun shadcn@latest add @gooseui/tabs

Usage

import { Tabs, TabsList, TabsTrigger, TabsContent } from "@/components/ui/tabs"

<Tabs defaultValue="profile">
  <TabsList aria-label="Account settings">
    <TabsTrigger value="profile">Profile</TabsTrigger>
    <TabsTrigger value="password">Password</TabsTrigger>
  </TabsList>
  <TabsContent value="profile">…</TabsContent>
  <TabsContent value="password">…</TabsContent>
</Tabs>

Examples

Account settings

The preview demo: fields, switches and buttons live inside the panels. The panels share one min-height, so the block keeps its size on switch: the new panel replaces the old one and the container does not jump.

<Tabs defaultValue="profile" className="w-full max-w-sm">
  <TabsList aria-label="Account settings" className="w-full">
    <TabsTrigger value="profile">Profile</TabsTrigger>
    <TabsTrigger value="password">Password</TabsTrigger>
    <TabsTrigger value="notifications">Notifications</TabsTrigger>
  </TabsList>
  <TabsContent value="profile" className="min-h-80 rounded-lg border p-5">
    <form className="grid gap-4">
      <div className="grid gap-2">
        <Label htmlFor="name">Name</Label>
        <Input id="name" defaultValue="Anna Petrova" />
      </div>
      <Button type="submit">Save profile</Button>
    </form>
  </TabsContent>
  <TabsContent value="notifications" className="min-h-80 rounded-lg border p-5">
    <Label htmlFor="digest">Weekly digest</Label>
    <Switch id="digest" defaultChecked />
  </TabsContent>
</Tabs>

Tabs with icons

This week at a glance

12 480 visits, 8% more than last week. 312 new sign-ups.

<TabsList aria-label="Views">
  <TabsTrigger value="overview" className="px-3">
    <LayoutDashboard aria-hidden="true" />
    Overview
  </TabsTrigger>
  <TabsTrigger value="analytics" className="px-3">
    <BarChart3 aria-hidden="true" />
    Analytics
  </TabsTrigger>
</TabsList>

Vertical tabs

orientation="vertical" puts the list beside the panel, and the pill glides vertically.

Workspace name and language

Shown in the header and in the emails your team receives.

<Tabs defaultValue="general" orientation="vertical">
  <TabsList aria-label="Settings sections">
    <TabsTrigger value="general" className="px-4">General</TabsTrigger>
    <TabsTrigger value="security" className="px-4">Security</TabsTrigger>
    <TabsTrigger value="billing" className="px-4">Billing</TabsTrigger>
  </TabsList>
  <TabsContent value="general">…</TabsContent>
  <TabsContent value="security">…</TabsContent>
  <TabsContent value="billing">…</TabsContent>
</Tabs>

Underline

variant="underline" drops the pill: a line under the active tab travels along the list rule.

Landing redesign

Due 12 December. Four of seven tasks are done.

<Tabs defaultValue="overview">
  <TabsList variant="underline" aria-label="Project sections">
    <TabsTrigger value="overview">Overview</TabsTrigger>
    <TabsTrigger value="activity">Activity</TabsTrigger>
    <TabsTrigger value="files">Files</TabsTrigger>
  </TabsList>
  <TabsContent value="overview">…</TabsContent>
</Tabs>

Props

PropTypeDefaultDescription
Tabs value / defaultValuestring-The selected tab. value makes it controlled, defaultValue sets the initial one.
Tabs onValueChange(value: string) => void-Called when another tab is picked.
Tabs orientation"horizontal" | "vertical""horizontal"The vertical layout puts the list beside the panel.
TabsList variant"default" | "underline""default"default: a pill on a muted track. underline: a line under the active tab along a shared rule.
TabsList indicatorClassNamestring-Classes for the moving indicator: colour, border, shadow or radius.
TabsTrigger valuestring-The tab's value. Other props go to the radio input, such as disabled.
TabsContent valuestring-The panel shows while the tab with the same value is selected. Give panels a shared min-height when they differ in size so the block does not jump.
classNamestring-Additional CSS classes on each of the four parts.