import { Slot } from "@radix-ui/react-slot"; import { cva, type VariantProps } from "class-variance-authority"; import { ComponentProps } from "react"; import { cn } from "../hooks"; const badgeVariants = cva( [ "inline-flex", "items-center", "justify-center", "rounded-uk-sm", "px-md", "py-xxs", "align-middle", "text-xs", "leading-uk-sm", "w-fit", "whitespace-nowrap", "shrink-0", "[&>svg]:size-3", "[&>svg]:pointer-events-none", "transition-[color,box-shadow]", "overflow-hidden", "text-text-withbg", ], { variants: { variant: { default: "bg-brand-primary", outline: "text-text-primary bg-transparent border border-bg-tertiary", secondary: "bg-bg-secondary text-text-primary", destructive: "bg-danger-primary", success: "bg-accent-success", warning: "bg-accent-warning", }, type: { default: "", circle: "size-[18px] !rounded-full", dot: "size-[6px] rounded-full !px-0 !py-0 text-transparent", }, }, defaultVariants: { variant: "default", type: "default", }, }, ); function Badge({ className, variant, type, asChild = false, ...props }: ComponentProps<"span"> & VariantProps & { asChild?: boolean }) { const Comp = asChild ? Slot : "span"; /** * Inline status badge. * * @param variant - Visual variant (default | secondary | destructive | success | warning | accent) * @param type - Shape type (default | circle | dot) * @param asChild - Render child element instead of span when true */ return ( ); } export { Badge, badgeVariants };