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.

72 linesCodeBlameRaw
1import { MoreHorizontal } from "lucide-react";
2import { Slot } from "radix-ui";
3import type { ComponentProps } from "react";
4
5import { cn } from "../../lib/cn";
6
7// shadcn/ui's breadcrumb, styled with g1t's tokens: where you are as a
8// trail of links, the page you are on last and not a link of its own
9// (BreadcrumbPage), with a quiet `/` between. `asChild` on a link puts its
10// look on a router <Link>.
11
12export function Breadcrumb(props: ComponentProps<"nav">) {
13 return <nav aria-label="Breadcrumb" data-slot="breadcrumb" {...props} />;
14}
15
16export function BreadcrumbList({ className, ...props }: ComponentProps<"ol">) {
17 return <ol data-slot="breadcrumb-list" className={cn("flex min-w-0 items-center gap-1 text-sm text-muted", className)} {...props} />;
18}
19
20export function BreadcrumbItem({ className, ...props }: ComponentProps<"li">) {
21 return <li data-slot="breadcrumb-item" className={cn("inline-flex min-w-0 items-center gap-1", className)} {...props} />;
22}
23
24export function BreadcrumbLink({ asChild, className, ...props }: ComponentProps<"a"> & { asChild?: boolean }) {
25 const Comp = asChild ? Slot.Root : "a";
26 return (
27 <Comp
28 data-slot="breadcrumb-link"
29 className={cn(
30 "truncate rounded-md px-1.5 py-1 outline-none transition-colors hover:bg-raised hover:text-fg focus-visible:ring-2 focus-visible:ring-accent",
31 className,
32 )}
33 {...props}
34 />
35 );
36}
37
38/** The page you are on: the trail's end, in the foreground. */
39export function BreadcrumbPage({ asChild, className, ...props }: ComponentProps<"span"> & { asChild?: boolean }) {
40 const Comp = asChild ? Slot.Root : "span";
41 return (
42 <Comp
43 data-slot="breadcrumb-page"
44 aria-current="page"
45 className={cn("truncate rounded-md px-1.5 py-1 font-medium text-fg outline-none focus-visible:ring-2 focus-visible:ring-accent", className)}
46 {...props}
47 />
48 );
49}
50
51export function BreadcrumbSeparator({ children, className, ...props }: ComponentProps<"li">) {
52 return (
53 <li data-slot="breadcrumb-separator" role="presentation" aria-hidden="true" className={cn("text-line-strong select-none", className)} {...props}>
54 {children ?? "/"}
55 </li>
56 );
57}
58
59export function BreadcrumbEllipsis({ className, ...props }: ComponentProps<"span">) {
60 return (
61 <span
62 data-slot="breadcrumb-ellipsis"
63 role="presentation"
64 aria-hidden="true"
65 className={cn("flex size-8 items-center justify-center", className)}
66 {...props}
67 >
68 <MoreHorizontal size={16} />
69 <span className="sr-only">More</span>
70 </span>
71 );
72}