28 lines
1.1 KiB
TypeScript
28 lines
1.1 KiB
TypeScript
|
|
import { HTMLAttributes } from 'react';
|
||
|
|
import { cn } from '@/lib/utils/cn';
|
||
|
|
|
||
|
|
export interface BadgeProps extends HTMLAttributes<HTMLDivElement> {
|
||
|
|
variant?: 'default' | 'secondary' | 'success' | 'warning' | 'destructive' | 'outline';
|
||
|
|
}
|
||
|
|
|
||
|
|
export function Badge({ className, variant = 'default', ...props }: BadgeProps) {
|
||
|
|
return (
|
||
|
|
<div
|
||
|
|
className={cn(
|
||
|
|
'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',
|
||
|
|
{
|
||
|
|
'border-transparent bg-primary text-primary-foreground': variant === 'default',
|
||
|
|
'border-transparent bg-secondary text-secondary-foreground': variant === 'secondary',
|
||
|
|
'border-transparent bg-success text-success-foreground': variant === 'success',
|
||
|
|
'border-transparent bg-warning text-warning-foreground': variant === 'warning',
|
||
|
|
'border-transparent bg-destructive text-destructive-foreground': variant === 'destructive',
|
||
|
|
'text-foreground': variant === 'outline',
|
||
|
|
},
|
||
|
|
className
|
||
|
|
)}
|
||
|
|
{...props}
|
||
|
|
/>
|
||
|
|
);
|
||
|
|
}
|