43 lines
1.1 KiB
TypeScript
43 lines
1.1 KiB
TypeScript
import type { HTMLAttributes, ReactNode } from 'react';
|
|
import { cva, type VariantProps } from 'class-variance-authority';
|
|
import { cn } from '@utils/cn';
|
|
|
|
const badgeVariants = cva(
|
|
'inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium',
|
|
{
|
|
variants: {
|
|
variant: {
|
|
default: 'bg-gray-100 text-gray-800',
|
|
primary: 'bg-primary-100 text-primary-800',
|
|
success: 'bg-success-50 text-success-700',
|
|
warning: 'bg-warning-50 text-warning-700',
|
|
danger: 'bg-danger-50 text-danger-700',
|
|
info: 'bg-blue-100 text-blue-800',
|
|
},
|
|
size: {
|
|
sm: 'px-2 py-0.5 text-xs',
|
|
md: 'px-2.5 py-0.5 text-xs',
|
|
lg: 'px-3 py-1 text-sm',
|
|
},
|
|
},
|
|
defaultVariants: {
|
|
variant: 'default',
|
|
size: 'md',
|
|
},
|
|
}
|
|
);
|
|
|
|
export interface BadgeProps
|
|
extends HTMLAttributes<HTMLSpanElement>,
|
|
VariantProps<typeof badgeVariants> {
|
|
children: ReactNode;
|
|
}
|
|
|
|
export function Badge({ children, variant, size, className, ...props }: BadgeProps) {
|
|
return (
|
|
<span className={cn(badgeVariants({ variant, size }), className)} {...props}>
|
|
{children}
|
|
</span>
|
|
);
|
|
}
|