Skip to content

Where people and agents ship software together. The open-source git platform for the whole job: issues, agents, checks and deploys to the edge.

g1t.sh
56 linesCodeBlameRaw
1import { Tabs as Primitive } from "radix-ui";
2import type { ComponentProps } from "react";
3
4import { cn } from "../../lib/cn";
5
6// shadcn/ui's tabs, styled with g1t's tokens. `variant="rail"` lays the
7// list out as a column of steps, each trigger a full-width row with room
8// for an icon and a line under its title (Getting started's step rail);
9// give the Tabs `orientation="vertical"` so the arrow keys go up and down.
10
11type Variant = "default" | "rail";
12
13export const Tabs = Primitive.Root;
14
15const LISTS: Record<Variant, string> = {
16 default: "inline-flex items-center gap-1 rounded-lg border border-line bg-bg p-1",
17 rail: "flex flex-col items-stretch gap-0.5",
18};
19
20const TRIGGERS: Record<Variant, string> = {
21 default: cn(
22 "rounded-md px-2.5 py-1 text-xs font-medium text-muted transition-colors outline-none hover:text-fg",
23 "data-[state=active]:bg-raised data-[state=active]:text-fg",
24 "disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:text-muted",
25 ),
26 rail: cn(
27 "flex w-full items-start gap-3 rounded-lg px-3 py-2.5 text-left text-sm text-muted transition-colors outline-none",
28 "hover:bg-raised/60 hover:text-fg focus-visible:ring-1 focus-visible:ring-accent/40 focus-visible:ring-inset",
29 "data-[state=active]:bg-raised data-[state=active]:text-fg",
30 ),
31};
32
33export function TabsList({
34 className,
35 variant = "default",
36 ...props
37}: ComponentProps<typeof Primitive.List> & { variant?: Variant }) {
38 return <Primitive.List className={cn(LISTS[variant], className)} {...props} />;
39}
40
41export function TabsTrigger({
42 className,
43 variant = "default",
44 ...props
45}: ComponentProps<typeof Primitive.Trigger> & { variant?: Variant }) {
46 return <Primitive.Trigger className={cn(TRIGGERS[variant], className)} {...props} />;
47}
48
49export function TabsContent({
50 className,
51 ...props
52}: ComponentProps<typeof Primitive.Content>) {
53 return (
54 <Primitive.Content className={cn("mt-3 outline-none", className)} {...props} />
55 );
56}