Collapsing Breadcrumb
NewCustomize
Width380px
Hover
Max visible0
Chevron
Installation
npx shadcn@latest add https://uibrik.com/r/collapsing-breadcrumb.jsonInstall the packages
npm install @tabler/icons-react motionAdd the cn helper
Imports
cnfrom@/lib/utils, whichshadcn initcreates. Add it by hand without shadcn.Copy the source into your project
components/uibrik/collapsing-breadcrumb/collapsing-breadcrumb.tsx"use client"; import { IconChevronRight, IconDots } from "@tabler/icons-react"; import { motion, useReducedMotion } from "motion/react"; import { Fragment, useEffect, useLayoutEffect, useRef, useState, type ElementType, type MouseEvent, type ReactNode, } from "react"; import { cn } from "@/lib/utils"; // Critically damped, so a fold that reverses mid-way keeps its velocity and // settles without overshoot. const FOLD = { type: "spring", duration: 0.4, bounce: 0 } as const; const EASE_OUT: [number, number, number, number] = [0.23, 1, 0.32, 1]; const HOVER_OPEN = 80; const HOVER_CLOSE = 320; export type BreadcrumbItem = {
Adds the files to
components/uibrik/collapsing-breadcrumb and installs @tabler/icons-react and motion. With the @uibrik namespace set up: npx shadcn@latest add @uibrik/collapsing-breadcrumb.Usage
import { CollapsingBreadcrumb } from "@/components/uibrik/collapsing-breadcrumb/collapsing-breadcrumb";const items = [ { label: "Home", href: "#", icon: <IconHome stroke={1.75} /> }, { label: "Acme Inc", href: "#" }, // …4 more];<CollapsingBreadcrumb items={items} expandOn="hover" maxVisible={0} separator="chevron" linkAs="a" label="Breadcrumb"/>Props
CollapsingBreadcrumb- expandOn
- Type "hover" | "click"
- "hover"
- What unfolds the hidden crumbs. Click and tap always work.
- maxVisible
- Type number
- 0
- Most crumbs shown while folded. 0 fits as many as the width allows.
- separator
- Type "chevron" | "slash"
- "chevron"
- Mark between crumbs.
- itemsrequired
- Type { label: string; href?: string; icon?: ReactNode }[]
- –
- The trail from the root to the current page. The last item is the current page.
- linkAs
- Type ElementType
- "a"
- Element for links, e.g. Next.js Link.
- label
- Type string
- "Breadcrumb"
- Accessible name for the nav.
- className
- Type string
- –
- Classes for the nav.