You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

badge.tsx 1.2KB

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