breadcrumb.jsx 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. import * as React from "react";
  2. import { Slot } from "@radix-ui/react-slot";
  3. import { ChevronRight, MoreHorizontal } from "lucide-react";
  4. import { cn } from "@/lib/utils";
  5. function Breadcrumb({ ...props }) {
  6. return <nav aria-label="breadcrumb" data-slot="breadcrumb" {...props} />;
  7. }
  8. function BreadcrumbList({ className, ...props }) {
  9. return (
  10. <ol
  11. data-slot="breadcrumb-list"
  12. className={cn(
  13. "text-muted-foreground flex flex-wrap items-center gap-1.5 text-sm wrap-break-word sm:gap-2.5",
  14. className,
  15. )}
  16. {...props}
  17. />
  18. );
  19. }
  20. function BreadcrumbItem({ className, ...props }) {
  21. return (
  22. <li
  23. data-slot="breadcrumb-item"
  24. className={cn("inline-flex items-center gap-1.5", className)}
  25. {...props}
  26. />
  27. );
  28. }
  29. function BreadcrumbLink({ asChild, className, ...props }) {
  30. const Comp = asChild ? Slot : "a";
  31. return (
  32. <Comp
  33. data-slot="breadcrumb-link"
  34. className={cn("hover:text-foreground transition-colors", className)}
  35. {...props}
  36. />
  37. );
  38. }
  39. function BreadcrumbPage({ className, ...props }) {
  40. return (
  41. <span
  42. data-slot="breadcrumb-page"
  43. role="link"
  44. aria-disabled="true"
  45. aria-current="page"
  46. className={cn("text-foreground font-normal", className)}
  47. {...props}
  48. />
  49. );
  50. }
  51. function BreadcrumbSeparator({ children, className, ...props }) {
  52. return (
  53. <li
  54. data-slot="breadcrumb-separator"
  55. role="presentation"
  56. aria-hidden="true"
  57. className={cn("[&>svg]:size-3.5", className)}
  58. {...props}
  59. >
  60. {children ?? <ChevronRight />}
  61. </li>
  62. );
  63. }
  64. function BreadcrumbEllipsis({ className, ...props }) {
  65. return (
  66. <span
  67. data-slot="breadcrumb-ellipsis"
  68. role="presentation"
  69. aria-hidden="true"
  70. className={cn("flex size-9 items-center justify-center", className)}
  71. {...props}
  72. >
  73. <MoreHorizontal className="size-4" />
  74. <span className="sr-only">Mehr</span>
  75. </span>
  76. );
  77. }
  78. export {
  79. Breadcrumb,
  80. BreadcrumbList,
  81. BreadcrumbItem,
  82. BreadcrumbLink,
  83. BreadcrumbPage,
  84. BreadcrumbSeparator,
  85. BreadcrumbEllipsis,
  86. };