badge.tsx 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-lg border px-2.5 py-0.5 text-xs font-semibold transition-all duration-200 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-hover',
  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 hover:bg-accent'
  17        }
  18      },
  19      defaultVariants: {
  20        variant: 'default'
  21      }
  22    }
  23  )
  24  
  25  export interface BadgeProps
  26    extends React.HTMLAttributes<HTMLDivElement>,
  27      VariantProps<typeof badgeVariants> {}
  28  
  29  function Badge({ className, variant, ...props }: BadgeProps) {
  30    return <div className={cn(badgeVariants({ variant }), className)} {...props} />
  31  }
  32  
  33  export { Badge, badgeVariants }
  34