43 lines
1.0 KiB
TypeScript
43 lines
1.0 KiB
TypeScript
import { cva, type VariantProps } from "class-variance-authority";
|
|
|
|
import { cn } from "@/lib/utils";
|
|
|
|
const badgeVariants = cva(
|
|
"inline-flex h-6 items-center rounded-md border px-2 py-0.5 text-xs font-semibold",
|
|
{
|
|
variants: {
|
|
variant: {
|
|
default: "border-transparent bg-primary text-primary-foreground",
|
|
secondary:
|
|
"border-transparent bg-secondary text-secondary-foreground",
|
|
outline:
|
|
"border-border/90 bg-background/70 text-foreground hover:bg-muted/50",
|
|
destructive:
|
|
"border-transparent bg-destructive text-destructive-foreground",
|
|
},
|
|
},
|
|
defaultVariants: {
|
|
variant: "default",
|
|
},
|
|
},
|
|
);
|
|
|
|
type BadgeProps = React.HTMLAttributes<HTMLDivElement> &
|
|
VariantProps<typeof badgeVariants>;
|
|
|
|
const Badge = ({ className, variant, ...props }: BadgeProps) => (
|
|
<span
|
|
className={cn(
|
|
badgeVariants({
|
|
variant,
|
|
}),
|
|
className,
|
|
)}
|
|
{...props}
|
|
/>
|
|
);
|
|
|
|
Badge.displayName = "Badge";
|
|
|
|
export { Badge, badgeVariants };
|