-
Notifications
You must be signed in to change notification settings - Fork 380
Expand file tree
/
Copy pathBadge.tsx
More file actions
32 lines (28 loc) · 834 Bytes
/
Badge.tsx
File metadata and controls
32 lines (28 loc) · 834 Bytes
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
import { Slot } from '@radix-ui/react-slot'
import { type VariantProps } from 'class-variance-authority'
import React from 'react'
import { type Size, type Shape } from '@/types/enums'
import { cn } from '@/utils'
import { badgeVariants } from './help'
import './Badge.css'
export interface BadgeProps
extends React.HTMLAttributes<HTMLSpanElement>,
VariantProps<typeof badgeVariants> {
asChild?: boolean
size?: Size
shape?: Shape
}
export const Badge = React.forwardRef<HTMLSpanElement, BadgeProps>(
({ className, size, shape, asChild = false, ...props }, ref) => {
const Comp = asChild ? Slot : 'span'
return (
<Comp
className={cn(badgeVariants({ size, shape, className }))}
ref={ref}
data-component="Badge"
{...props}
/>
)
},
)
Badge.displayName = 'Badge'