Skip to content
Pebble Pro is here at $49 one timeSee what’s included ↗
Pebble
ComponentsDocsMCPPricing
⌕ Find a component↗Log in
All components 673

Categories

Core inputs & forms46Buttons & actions33Navigation36Overlays & feedback49Data display33Charts & data viz40Cards & layout43Marketing blocks38App shells & pages37AI interfaces40Text & typography effects33Backgrounds & visual effects38Motion & transitions32Numbers & counters32Media34E-commerce333D & interactive36Themed sets40
Start with the essentials.Installation guide ↗Connect your agent ↗
← All componentsNavigation

Tabs

Switch between panels with a row or column of tabs, in a tray or underline style, built on the Radix Tabs primitive.

Preview

Pebble redesign

Open tasks

12

+3 this week

Due Friday

3

2 assigned to you

Shipped in May

48

96% on time

// retry with backoff
await retry(sync, { tries: 3 });
9 threads, oldest from Tuesday.

Team plan · renews Dec 1

$1,284.50

6 seats · billed yearly

Install

Add the editable source with the shadcn CLI. Your project also needs the shared theme tokens this component uses. Setup and requirements. The Pebble installer is not published yet.

npx shadcn@latest add https://pebbleui.com/r/tabs.json

Props

PropTypeDefaultDescription
value / defaultValuestring-Tabs: controlled or initial active tab.
onValueChange(value: string) => void-Tabs: called when the active tab changes.
orientation"horizontal" | "vertical""horizontal"Tabs: layout and arrow-key axis.
activationMode"automatic" | "manual""automatic"Tabs: activate on focus, or only on Enter/Space.
variant"default" | "line" | "pill""default"TabsList: muted tray with raised chip, underline, or separate pills with a lit-key indicator.
loopbooleantrueTabsList: arrow keys wrap around.
disabledbooleanfalseTabsTrigger: skip and dim the tab.
Build notes
Built on the Radix Tabs primitive, which provides roving focus, activation and the ARIA wiring, and sets `data-orientation` on root and list and `data-state` on triggers and panels. `Tabs` is a flex container (`group/tabs`) that becomes a column when horizontal so the list sits above the panel; vertical leaves it a row. `TabsList` carries `group/tabs-list` and `data-variant`, so triggers style themselves from both ancestors with `group-data-[...]` variants rather than React context, keeping it a plain class-based component. The `line` indicator is the trigger's `::after`: absolutely positioned, `bg-foreground`, 2 px, placed at `-bottom-px` (horizontal) or `-end-px` (vertical) so it overlaps the list's 1 px border, with opacity 0 to 1 on `data-state=active`. The indicator does not slide between tabs; it fades, which keeps the component free of measurement and works with reduced motion trivially. Vertical uses logical `border-e`/`end` so RTL mirrors. Compared with the source, the `cva` dependency is replaced by a plain object map, and the dark-mode `input` token styling is dropped since this library has no `input` token.

**Pebble (2026-11-03).** Each `Tabs` mirrors its active value in state (a controlled `value` wins) and shares it with a `useId` through context, so the active trigger renders one `motion.span` (`data-slot="tabs-indicator"`) with `layoutId={id + "-indicator"}`; when the value changes the indicator springs (stiffness 420, damping 32, mass 0.8) from the old tab to the new one instead of fading. `MotionConfig reducedMotion="user"` makes the move instant under reduced motion. The indicator sits at `-z-10` inside a `relative isolate` trigger, so labels stay above it. Three looks: `default` is a recessed tray (`bg-muted inset-shadow-xs ring-hairline`) with a raised card chip (`bg-card shadow-raised-xs ring-hairline inset-shadow-highlight`); `line` is a hairline rule with a 2 px ember (`bg-accent`) bar that sits on the border (list padding `pb-1` / `pe-1.5` with the bar at `-bottom-[5px]` / `-end-[7px]`), and triggers get a `bg-muted` hover wash; `pill` (new) is loose rounded keys where the active one is the lit key (key gradient, `ring-key-edge`, key shine). Panels enter with a 4 px rise and fade from `@starting-style` (`starting:translate-y-1 starting:opacity-0`, `--motion-base`, `ease-enter`); under reduced motion only the fade remains. Type is 13 px medium, focus uses the `ring-2 ring-offset-2` token ring.

<!-- PEBBLE-LICENSE -->
View source

registry/nav/tabs/tabs.tsx

"use client";

/* PEBBLE-LICENSE
Built by Pebble. Component: tabs.

First-party license: MIT

The following first-party terms apply only to original Pebble material.

MIT License

Copyright (c) 2026 Praxys Solutions LLC (Pebble)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

THIRD-PARTY NOTICES
These notices apply to identified upstream portions; Pebble terms do not replace or narrow their rights.

Upstream: https://raw.githubusercontent.com/shadcn-ui/ui/main/LICENSE.md
MIT License

Copyright (c) 2023 shadcn

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
END PEBBLE-LICENSE */

import * as React from "react";
import { MotionConfig, motion } from "motion/react";
import { Tabs as TabsPrimitive } from "radix-ui";

import { cn } from "@/lib/utils";

// Hydration-safe reduced motion: the server (and the hydration pass) render
// "no preference", then the real preference applies right after hydration.
const subscribeReduce = (onChange: () => void) => {
  const mq = window.matchMedia("(prefers-reduced-motion: reduce)");
  mq.addEventListener("change", onChange);
  return () => mq.removeEventListener("change", onChange);
};
const getReduce = () => window.matchMedia("(prefers-reduced-motion: reduce)").matches;
const useReduceMotion = () => React.useSyncExternalStore(subscribeReduce, getReduce, () => false);

// Pebble: one indicator per Tabs, shared through `layoutId`, so the active
// chip (or bar, or key) slides from tab to tab instead of cross-fading.
const spring = { type: "spring", stiffness: 420, damping: 32, mass: 0.8 } as const;

type TabsContextValue = { value: string | undefined; id: string };
const TabsContext = React.createContext<TabsContextValue | null>(null);

export function Tabs({
  value: valueProp,
  defaultValue,
  onValueChange,
  orientation = "horizontal",
  className,
  children,
  ...props
}: React.ComponentProps<typeof TabsPrimitive.Root>) {
  // Mirror the active value so triggers know where the indicator lives. A
  // controlled `value` always wins; otherwise follow Radix's own changes.
  const [inner, setInner] = React.useState(defaultValue);
  const value = valueProp ?? inner;
  const reduced = useReduceMotion();
  const id = React.useId();
  const context = React.useMemo(() => ({ value, id }), [value, id]);
  return (
    <TabsContext.Provider value={context}>
      <MotionConfig reducedMotion={reduced ? "always" : "never"}>
        <TabsPrimitive.Root
          data-slot="tabs"
          orientation={orientation}
          value={value}
          onValueChange={(next) => {
            if (valueProp === undefined) setInner(next);
            onValueChange?.(next);
          }}
          className={cn("group/tabs flex gap-3 data-[orientation=horizontal]:flex-col", className)}
          {...props}
        >
          {children}
        </TabsPrimitive.Root>
      </MotionConfig>
    </TabsContext.Provider>
  );
}

const listVariants = {
  // A recessed tray; the active tab is a raised pebble chip that slides.
  default: "gap-0.5 rounded-lg bg-muted p-1 ring-1 ring-hairline inset-shadow-xs",
  // No tray; a hairline rule with an ember bar under (or beside) the active tab.
  line: "gap-1 border-border group-data-[orientation=horizontal]/tabs:border-b group-data-[orientation=horizontal]/tabs:pb-1 group-data-[orientation=vertical]/tabs:border-e group-data-[orientation=vertical]/tabs:pe-1.5",
  // Loose keys on the page; the active one is the lit key.
  pill: "gap-1",
} as const;

export type TabsVariant = keyof typeof listVariants;

const ListContext = React.createContext<TabsVariant>("default");

export type TabsListProps = React.ComponentProps<typeof TabsPrimitive.List> & {
  variant?: TabsVariant;
};

export function TabsList({ variant = "default", className, ...props }: TabsListProps) {
  return (
    <ListContext.Provider value={variant}>
      <TabsPrimitive.List
        data-slot="tabs-list"
        data-variant={variant}
        className={cn(
          "group/tabs-list relative inline-flex w-fit items-center justify-center text-muted-foreground group-data-[orientation=vertical]/tabs:flex-col group-data-[orientation=vertical]/tabs:items-stretch",
          listVariants[variant],
          className,
        )}
        {...props}
      />
    </ListContext.Provider>
  );
}

const triggerVariants = {
  default: "h-8 rounded-md px-3",
  line: "h-9 rounded-md px-3 hover:bg-muted",
  pill: "h-8 rounded-full px-3.5 hover:bg-muted data-[state=active]:text-primary-foreground data-[state=active]:hover:bg-transparent",
} as const;

const indicatorVariants = {
  default:
    "inset-0 rounded-md bg-card shadow-raised-xs ring-1 ring-hairline inset-shadow-highlight",
  line: "rounded-full bg-accent group-data-[orientation=horizontal]/tabs:inset-x-2 group-data-[orientation=horizontal]/tabs:-bottom-[5px] group-data-[orientation=horizontal]/tabs:h-0.5 group-data-[orientation=vertical]/tabs:inset-y-1.5 group-data-[orientation=vertical]/tabs:-end-[7px] group-data-[orientation=vertical]/tabs:w-0.5",
  pill: "inset-0 rounded-full bg-linear-to-b from-key-top to-key-bottom shadow-[var(--key-shine),var(--elevation-sm)] ring-1 ring-key-edge",
} as const;

export function TabsTrigger({
  value,
  className,
  children,
  ...props
}: React.ComponentProps<typeof TabsPrimitive.Trigger>) {
  const tabs = React.useContext(TabsContext);
  const variant = React.useContext(ListContext);
  const active = tabs !== null && tabs.value === value;
  return (
    <TabsPrimitive.Trigger
      data-slot="tabs-trigger"
      value={value}
      className={cn(
        "relative isolate inline-flex flex-1 cursor-pointer items-center justify-center gap-1.5 text-[13px] font-medium whitespace-nowrap text-muted-foreground select-none",
        "transition-[color,background-color] duration-(--motion-fast) ease-enter motion-reduce:transition-none",
        "hover:text-foreground data-[state=active]:text-foreground",
        "focus-visible:z-10 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background focus-visible:outline-hidden",
        "disabled:pointer-events-none disabled:opacity-50",
        "group-data-[orientation=vertical]/tabs:w-full group-data-[orientation=vertical]/tabs:justify-start",
        "[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
        triggerVariants[variant],
        // Forced colors drop the indicator; outline the active tab.
        "forced-colors:data-[state=active]:outline-2 forced-colors:data-[state=active]:outline-[Highlight] forced-colors:data-[state=active]:outline-solid",
        className,
      )}
      {...props}
    >
      {active ? (
        <motion.span
          aria-hidden
          data-slot="tabs-indicator"
          layoutId={`${tabs.id}-indicator`}
          transition={spring}
          className={cn("pointer-events-none absolute -z-10", indicatorVariants[variant])}
        />
      ) : null}
      {children}
    </TabsPrimitive.Trigger>
  );
}

export function TabsContent({
  className,
  ...props
}: React.ComponentProps<typeof TabsPrimitive.Content>) {
  return (
    <TabsPrimitive.Content
      data-slot="tabs-content"
      className={cn(
        "flex-1 rounded-md outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background",
        // Enter: fade plus a 4px rise from the panel's starting style.
        "transition-[opacity,translate] duration-(--motion-base) ease-enter motion-reduce:transition-[opacity] starting:translate-y-1 starting:opacity-0 motion-reduce:starting:translate-y-0",
        className,
      )}
      {...props}
    />
  );
}
Pebble

Small details.
Better interfaces.

React components to explore, make your own, and build on.

Library

  • Components
  • Installation
  • Pricing

Resources

  • For agents
  • About
  • Support

Legal

  • License
  • Terms
  • Privacy
  • Final sale

Built by Pebble

A product of Praxys Solutions LLC ↗

Pebble Pro is live

$49 one time, lifetime updates ↗