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.

40 linesCodeBlameRaw
1import { type VariantProps, cva } from "class-variance-authority";
2import type { ComponentProps } from "react";
3
4import { cn } from "../../lib/cn";
5
6// shadcn/ui's badge, styled with g1t's tokens: a small outlined label whose
7// tone says how much it matters. `sm` (the default) is the 11px label beside
8// a title or in a table; `md` the 12px pill in a list of properties. Shape
9// `mark` is a round 24px cap for a step's number or tick.
10
11export const badgeVariants = cva("inline-flex shrink-0 items-center gap-1 border whitespace-nowrap", {
12 variants: {
13 tone: {
14 neutral: "border-line text-muted",
15 accent: "border-accent/40 bg-accent/10 text-accent",
16 success: "border-success/40 bg-success/10 text-success",
17 info: "border-info/40 bg-info/10 text-info",
18 merged: "border-merged/40 bg-merged/10 text-merged",
19 warn: "border-warn/40 bg-warn/10 text-warn",
20 danger: "border-danger/40 bg-danger/10 text-danger",
21 },
22 size: {
23 sm: "px-2 py-px text-[0.6875rem] font-medium",
24 md: "px-2 py-0.5 text-xs",
25 },
26 shape: {
27 pill: "rounded-full",
28 tag: "rounded",
29 // A step's number or tick: a 24px round mark with one glyph centred.
30 mark: "size-6 justify-center rounded-full p-0",
31 },
32 },
33 defaultVariants: { tone: "neutral", size: "sm", shape: "pill" },
34});
35
36export type BadgeTone = NonNullable<VariantProps<typeof badgeVariants>["tone"]>;
37
38export function Badge({ tone, size, shape, className, ...props }: ComponentProps<"span"> & VariantProps<typeof badgeVariants>) {
39 return <span data-slot="badge" className={cn(badgeVariants({ tone, size, shape }), className)} {...props} />;
40}