diff options
| author | aman333nolawz <amananudhiu@gmail.com> | 2026-03-02 21:49:13 +0530 |
|---|---|---|
| committer | aman333nolawz <amananudhiu@gmail.com> | 2026-03-02 21:49:13 +0530 |
| commit | d41eff9eccf66644c4c60f53cb516bf079937a28 (patch) | |
| tree | 248a0863a3181369f943d678ec4273911d35efac /src/components/ui/breadcrumb.tsx | |
Using astro-erudite for static site generation
Diffstat (limited to 'src/components/ui/breadcrumb.tsx')
| -rw-r--r-- | src/components/ui/breadcrumb.tsx | 108 |
1 files changed, 108 insertions, 0 deletions
diff --git a/src/components/ui/breadcrumb.tsx b/src/components/ui/breadcrumb.tsx new file mode 100644 index 0000000..a639b0c --- /dev/null +++ b/src/components/ui/breadcrumb.tsx @@ -0,0 +1,108 @@ +import * as React from 'react' +import { Slot as SlotPrimitive } from 'radix-ui' +import { cn } from '@/lib/utils' +import { ChevronRight, MoreHorizontal } from 'lucide-react' + +function Breadcrumb({ ...props }: React.ComponentProps<'nav'>) { + return <nav aria-label="breadcrumb" data-slot="breadcrumb" {...props} /> +} + +function BreadcrumbList({ className, ...props }: React.ComponentProps<'ol'>) { + return ( + <ol + data-slot="breadcrumb-list" + className={cn( + 'text-muted-foreground flex flex-wrap items-center gap-1.5 text-sm break-words sm:gap-2.5', + className, + )} + {...props} + /> + ) +} + +function BreadcrumbItem({ className, ...props }: React.ComponentProps<'li'>) { + return ( + <li + data-slot="breadcrumb-item" + className={cn('inline-flex items-center gap-1.5', className)} + {...props} + /> + ) +} + +function BreadcrumbLink({ + asChild, + className, + ...props +}: React.ComponentProps<'a'> & { + asChild?: boolean +}) { + const Comp = asChild ? SlotPrimitive.Root : 'a' + + return ( + <Comp + data-slot="breadcrumb-link" + className={cn('hover:text-foreground transition-colors', className)} + {...props} + /> + ) +} + +function BreadcrumbPage({ className, ...props }: React.ComponentProps<'span'>) { + return ( + <span + data-slot="breadcrumb-page" + role="link" + aria-disabled="true" + aria-current="page" + className={cn('text-foreground font-normal', className)} + {...props} + /> + ) +} + +function BreadcrumbSeparator({ + children, + className, + ...props +}: React.ComponentProps<'li'>) { + return ( + <li + data-slot="breadcrumb-separator" + role="presentation" + aria-hidden="true" + className={cn('[&>svg]:size-3.5', className)} + {...props} + > + {children ?? <ChevronRight />} + </li> + ) +} + +function BreadcrumbEllipsis({ + className, + ...props +}: React.ComponentProps<'span'>) { + return ( + <span + data-slot="breadcrumb-ellipsis" + role="presentation" + aria-hidden="true" + className={cn('flex size-9 items-center justify-center', className)} + {...props} + > + <MoreHorizontal className="size-4" /> + <span className="sr-only">More</span> + </span> + ) +} + +export { + Breadcrumb, + BreadcrumbList, + BreadcrumbItem, + BreadcrumbLink, + BreadcrumbPage, + BreadcrumbSeparator, + BreadcrumbEllipsis, +} |
