OpChan/app/src/components/ui/badge.tsx

44 lines
1.2 KiB
TypeScript
Raw Normal View History

2025-08-30 18:34:50 +05:30
import * as React from 'react';
import { cva, type VariantProps } from 'class-variance-authority';
2025-04-15 16:28:03 +05:30
2025-08-30 18:34:50 +05:30
import { cn } from '@/lib/utils';
2025-04-15 16:28:03 +05:30
const badgeVariants = cva(
2025-08-30 18:34:50 +05:30
'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',
2025-04-15 16:28:03 +05:30
{
variants: {
variant: {
default:
2025-08-30 18:34:50 +05:30
'border-transparent bg-primary text-primary-foreground hover:bg-primary/80',
2025-04-15 16:28:03 +05:30
secondary:
2025-08-30 18:34:50 +05:30
'border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80',
2025-04-15 16:28:03 +05:30
destructive:
2025-08-30 18:34:50 +05:30
'border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80',
outline: 'text-foreground',
2025-04-15 16:28:03 +05:30
},
},
defaultVariants: {
2025-08-30 18:34:50 +05:30
variant: 'default',
2025-04-15 16:28:03 +05:30
},
}
2025-08-30 18:34:50 +05:30
);
2025-04-15 16:28:03 +05:30
export interface BadgeProps
extends React.HTMLAttributes<HTMLDivElement>,
VariantProps<typeof badgeVariants> {}
const Badge = React.forwardRef<HTMLDivElement, BadgeProps>(
({ className, variant, ...props }, ref) => {
return (
<div
className={cn(badgeVariants({ variant }), className)}
ref={ref}
{...props}
/>
2025-08-30 18:34:50 +05:30
);
}
2025-08-30 18:34:50 +05:30
);
Badge.displayName = 'Badge';
2025-04-15 16:28:03 +05:30
2025-08-30 18:34:50 +05:30
export { Badge };