flockstr/components/ui/badge.tsx

40 lines
1.3 KiB
TypeScript
Raw Normal View History

2023-10-14 12:09:44 -04:00
import * as React from "react";
import { cva, type VariantProps } from "class-variance-authority";
2023-10-13 09:23:11 -04:00
2023-10-14 12:09:44 -04:00
import { cn } from "@/lib/utils";
2023-10-13 09:23:11 -04:00
const badgeVariants = cva(
"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",
{
variants: {
variant: {
default:
"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",
secondary:
"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",
2023-10-14 12:09:44 -04:00
green:
"border-transparent bg-green-100 text-green-700 hover:bg-green-200/80",
2023-10-16 10:59:28 -04:00
red: "border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",
2023-10-13 09:23:11 -04:00
destructive:
"border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",
outline: "text-foreground",
},
},
defaultVariants: {
variant: "default",
},
2023-10-14 12:09:44 -04:00
},
);
2023-10-13 09:23:11 -04:00
export interface BadgeProps
extends React.HTMLAttributes<HTMLDivElement>,
VariantProps<typeof badgeVariants> {}
function Badge({ className, variant, ...props }: BadgeProps) {
return (
<div className={cn(badgeVariants({ variant }), className)} {...props} />
2023-10-14 12:09:44 -04:00
);
2023-10-13 09:23:11 -04:00
}
2023-10-14 12:09:44 -04:00
export { Badge, badgeVariants };