gitscope
← marzneshin / v0.3.0-alpha1 / dashboard/src/components/ui/badge.tsx
https://dev.kronoz.win/r/marzneshin.git
dashboard/src/components/ui/badge.tsx · TypeScript
Blame Raw
 1import * as React from "react"
 2import { cva, type VariantProps } from "class-variance-authority"
 3
 4import { cn } from "@marzneshin/utils"
 5
 6const 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:
12          "border-transparent bg-primary text-primary-foreground hover:bg-primary/80",
13        secondary:
14          "border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",
15        destructive:
16          "border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",
17        royal:
18          "border-transparent bg-indigo-300 text-indigo-700 hover:bg-indigo/80",
19        positive:
20          "border-transparent bg-emerald-300 text-emerald-700 hover:bg-emerald/80",
21        disabled:
22          "border-transparent bg-gray-400 text-gray-800 hover:bg-gray/80",
23        warning:
24          "border-transparent bg-amber-300 text-amber-700 hover:bg-amber/80",
25        outline: "text-foreground",
26      },
27    },
28    defaultVariants: {
29      variant: "default",
30    },
31  }
32)
33
34export interface BadgeProps
35  extends React.HTMLAttributes<HTMLDivElement>,
36  VariantProps<typeof badgeVariants> { }
37
38function Badge({ className, variant, ...props }: BadgeProps) {
39  return (
40    <div className={cn(badgeVariants({ variant }), className)} {...props} />
41  )
42}
43
44type BadgeVariantKeys =
45  | 'default'
46  | 'secondary'
47  | 'destructive'
48  | 'royal'
49  | 'positive'
50  | 'disabled'
51  | 'warning'
52  | 'outline';
53
54export { Badge, badgeVariants, type BadgeVariantKeys }