Tabs
Tabs with thoughtful defaults, semantic styling, and editable source.
Make it yours.
Install the editable source and its dependencies into your React + Tailwind project.
Scroll horizontally for long lines
pnpm dlx shadcn@4.0.8 add http://localhost:3000/r/tabs.jsonUse it
Scroll horizontally for long lines
"use client";
import {Tabs} from '@/components/jez-ui/ui/tabs';
export default function Example(){
return <><div className="w-full max-w-md"><h3 className="mb-5 text-2xl">Room for the whole process.</h3><Tabs items={[{value:'design',label:'Design',content:<div className="py-5"><p className="text-3xl">Start with a question.</p><p className="mt-3 text-sm text-muted-foreground">Sketch the possibilities before you choose a direction.</p></div>},{value:'build',label:'Build',content:<div className="py-5"><p className="text-3xl">Give it a useful shape.</p><p className="mt-3 text-sm text-muted-foreground">Make the smallest version that tells you something.</p></div>},{value:'share',label:'Share',content:<div className="py-5"><p className="text-3xl">Let someone try it.</p><p className="mt-3 text-sm text-muted-foreground">The next good idea might come from them.</p></div>}]}/></div></>;
}Props & types
Scroll horizontally for long lines
React.ComponentProps<typeof Primitive.Root> & {
items: { value: string; label: string; content: React.ReactNode }[];
}Source
View 2 source files
registry/ui/tabs.tsx
Scroll horizontally for long lines
"use client";
import * as React from "react";
import { cn } from "./utils";
import { Tabs as Primitive } from "radix-ui";
export function Tabs({
items,
className,
...props
}: React.ComponentProps<typeof Primitive.Root> & {
items: { value: string; label: string; content: React.ReactNode }[];
}) {
return (
<Primitive.Root
defaultValue={items[0]?.value}
className={cn("w-full", className)}
{...props}
>
<Primitive.List className="flex gap-1 border-b border-border">
{items.map((i) => (
<Primitive.Trigger
key={i.value}
value={i.value}
className="border-b-2 border-transparent px-4 py-3 text-sm data-[state=active]:border-primary data-[state=active]:text-primary"
>
{i.label}
</Primitive.Trigger>
))}
</Primitive.List>
{items.map((i) => (
<Primitive.Content key={i.value} value={i.value} className="py-5">
{i.content}
</Primitive.Content>
))}
</Primitive.Root>
);
}
registry/ui/utils.ts
Scroll horizontally for long lines
import { clsx, type ClassValue } from "clsx";
import { twMerge } from "tailwind-merge";
export function cn(...values: ClassValue[]) {
return twMerge(clsx(values));
}
Dependencies
radix-ui@1.6.7 · clsx@2.1.1 · tailwind-merge@3.5.0
Accessibility & behaviour
Provide meaningful labels and preserve keyboard focus styles. Check contrast when customising theme colours.
Read the accessibility and performance guide →