TWIGS

Tabs

A set of layered sections of content, also known as tab panels.

Playground

Your last 30 days of energy usage.
Your last 30 days of energy usage.

Installation

Install in any React + Tailwind project:

$npx shadcn@latest add https://twigs.globirdenergy.com.au/r/tabs.json

Source

The exact file the registry serves to consumers.

'use client';

import * as React from 'react';
import { Tabs as BaseTabs } from '@base-ui/react/tabs';
import { cn } from '@/lib/utils';

function Tabs({ className, ...props }: React.ComponentProps<typeof BaseTabs.Root>) {
  return <BaseTabs.Root data-slot="tabs" className={cn('flex flex-col gap-2', className)} {...props} />;
}

// Spec source: Figma "APP Re-design Phase 1" → page "Tabs ✅"
// Tab h=44, padding 28x 12y, radius 9999 (pill)
function TabsList({ className, ...props }: React.ComponentProps<typeof BaseTabs.List>) {
  return (
    <BaseTabs.List
      data-slot="tabs-list"
      className={cn(
        'bg-secondary text-muted-foreground inline-flex h-11 w-fit items-center justify-center rounded-full p-1',
        className,
      )}
      {...props}
    />
  );
}

function TabsTrigger({ className, ...props }: React.ComponentProps<typeof BaseTabs.Tab>) {
  return (
    <BaseTabs.Tab
      data-slot="tabs-trigger"
      className={cn(
        'inline-flex h-full flex-1 items-center justify-center gap-2.5 rounded-full border border-transparent px-7 py-3 text-sm font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 outline-none disabled:pointer-events-none disabled:opacity-50',
        'data-[active]:bg-background data-[active]:text-foreground data-[active]:shadow-md dark:data-[active]:bg-foreground dark:data-[active]:text-background',
        "[&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0",
        className,
      )}
      {...props}
    />
  );
}

function TabsContent({ className, ...props }: React.ComponentProps<typeof BaseTabs.Panel>) {
  return (
    <BaseTabs.Panel
      data-slot="tabs-content"
      className={cn('flex-1 outline-none', className)}
      {...props}
    />
  );
}

export { Tabs, TabsList, TabsTrigger, TabsContent };