main
tsx 36 lines 1.11 KB
Raw
1 import * as React from "react";
2 import { cva, type VariantProps } from "class-variance-authority";
3 import { cn } from "@/lib/utils";
4
5 const badgeVariants = cva(
6 "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",
7 {
8 variants: {
9 variant: {
10 default:
11 "border-transparent bg-primary text-primary-foreground hover:bg-primary/80",
12 secondary:
13 "border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",
14 destructive:
15 "border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",
16 outline: "text-foreground",
17 },
18 },
19 defaultVariants: {
20 variant: "default",
21 },
22 },
23 );
24
25 export interface BadgeProps
26 extends
27 React.HTMLAttributes<HTMLDivElement>,
28 VariantProps<typeof badgeVariants> {}
29
30 function Badge({ className, variant, ...props }: BadgeProps) {
31 return (
32 <div className={cn(badgeVariants({ variant }), className)} {...props} />
33 );
34 }
35
36 export { Badge, badgeVariants };