Breadcrumb
patchui/breadcrumbFreeComponent
patchui publishes no description for this item.
Install it
npx shadcn@latest add https://ui.hotfix.jobs/r/breadcrumb.jsonSource
1"use client";23import { Fragment, useState } from "react";4import type * as React from "react";5import { cn } from "@/lib/utils";6import { coarseTarget, selectionFocus } from "@/lib/recipes";78import { CaretRight, DotsThree, House } from "@phosphor-icons/react/dist/ssr";9export interface BreadcrumbItem {10 /** Label. If `href === "/"` and `name === "Home"`, renders as home icon. */11 name: string;12 /** If omitted, the crumb renders as a non-link (useful for the current page). */13 href?: string;14 /** Custom leading icon; overrides the auto home-icon behavior. */15 icon?: React.ReactNode;16}1718export interface BreadcrumbProps19 extends Omit<React.HTMLAttributes<HTMLElement>, "children"> {20 items: BreadcrumbItem[];21 /**22 * When true, treat any `<a>` element from your router as a Link. The default23 * uses `<a>`: pass a `linkAs` render prop if you need Next.js Link etc.24 */25 linkAs?: (props: {26 href: string;27 children: React.ReactNode;28 className?: string;29 "aria-label"?: string;30 "aria-current"?: "page";31 }) => React.ReactElement;32}3334function Separator() {35 return (36 <CaretRight37 aria-hidden38 className="size-3.5 shrink-0 text-ink-tertiary"39 />40 );41}4243/** Horizontal trail of ancestor links. Long chains collapse middle items on mobile. */44export function Breadcrumb({45 items,46 linkAs,47 className,48 ...props49}: BreadcrumbProps): React.ReactElement | null {50 const [expanded, setExpanded] = useState(false);51 if (items.length === 0) return null;5253 const collapseMiddle = items.length > 3;54 const LinkComponent =55 linkAs ??56 ((linkProps) => <a {...linkProps}>{linkProps.children}</a>);5758 return (59 <nav60 aria-label="Breadcrumb"61 data-slot="breadcrumb"62 className={cn("text-small", className)}63 {...props}64 >65 <ol className="flex items-center gap-2 overflow-x-auto whitespace-nowrap text-ink-muted [scrollbar-width:none] [-ms-overflow-style:none] [&::-webkit-scrollbar]:hidden">66 {items.map((item, idx) => {67 const isLast = idx === items.length - 1;68 const isMiddle = idx > 0 && !isLast;69 const hiddenOnMobile = collapseMiddle && isMiddle && !expanded;70 const isHome =71 item.icon === undefined &&72 item.href === "/" &&73 item.name === "Home";7475 const content =76 item.icon !== undefined ? (77 <>78 <span className="inline-flex shrink-0 items-center">79// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from patchui
All 51 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | patchui | Components | Free | 2 deps | |
| Avataravatar | patchui | Components | Free | 3 deps | |
| Badgebadge | patchui | Components | Free | 2 deps | |
| Buttonbutton | patchui | Components | Free | 2 deps | |
| Calendarcalendar | patchui | Components | Free | 1 dep | |
| Cardcard | patchui | Components | Free | 1 dep | |
| Checkboxcheckbox | patchui | Components | Free | 2 deps | |
| Comboboxcombobox | patchui | Components | Free | 3 deps |
