badge.jsx 990 B

12345678910111213141516171819202122232425262728293031323334
  1. import * as React from "react"
  2. import { cva } from "class-variance-authority";
  3. import { cn } from "@/lib/utils"
  4. const badgeVariants = cva(
  5. "inline-flex items-center rounded-md 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 shadow 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 shadow hover:bg-destructive/80",
  15. outline: "text-foreground",
  16. },
  17. },
  18. defaultVariants: {
  19. variant: "default",
  20. },
  21. }
  22. )
  23. function Badge({
  24. className,
  25. variant,
  26. ...props
  27. }) {
  28. return (<div className={cn(badgeVariants({ variant }), className)} {...props} />);
  29. }
  30. export { Badge, badgeVariants }