badge.tsx
1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import * as React from 'react';
import { cva, type VariantProps } from 'class-variance-authority';
import { cn } from '@/lib/utils';
const badgeVariants = cva(
'inline-flex items-center gap-1 rounded-full border px-2.5 py-0.5 text-xs font-medium transition-colors focus:outline-none whitespace-nowrap',
{
variants: {
variant: {
default: 'border-transparent bg-primary text-primary-foreground shadow-sm',
secondary:
'border-transparent bg-secondary text-secondary-foreground',
outline: 'border-border text-foreground',
brand:
'border-primary/25 bg-primary/12 text-primary',
neutral:
'border-border bg-muted text-muted-foreground',
success:
'border-emerald-500/20 bg-emerald-500/12 text-emerald-600 dark:text-emerald-400',
info: 'border-slate-500/20 bg-slate-500/12 text-slate-600 dark:text-slate-400',
warning:
'border-amber-500/20 bg-amber-500/12 text-amber-600 dark:text-amber-400',
danger:
'border-rose-500/20 bg-rose-500/12 text-rose-600 dark:text-rose-400',
},
},
defaultVariants: { variant: 'default' },
},
);
export interface BadgeProps
extends React.HTMLAttributes<HTMLDivElement>,
VariantProps<typeof badgeVariants> {}
function Badge({ className, variant, ...props }: BadgeProps) {
return (
<div className={cn(badgeVariants({ variant }), className)} {...props} />
);
}
export { Badge, badgeVariants };