main
tsx 29 lines 1.06 KB
Raw
1 import * as React from "react";
2 import { cva, type VariantProps } from "class-variance-authority";
3
4 import { cn } from "@/lib/utils";
5
6 const badgeVariants = cva(
7 "inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
8 {
9 variants: {
10 variant: {
11 default: "border-transparent bg-primary text-primary-foreground hover:bg-primary/80",
12 secondary: "border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",
13 destructive: "border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",
14 outline: "text-foreground",
15 },
16 },
17 defaultVariants: {
18 variant: "default",
19 },
20 },
21 );
22
23 export interface BadgeProps extends React.HTMLAttributes<HTMLDivElement>, VariantProps<typeof badgeVariants> {}
24
25 function Badge({ className, variant, ...props }: BadgeProps) {
26 return <div className={cn(badgeVariants({ variant }), className)} {...props} />;
27 }
28
29 export { Badge, badgeVariants };