Skip to content

Commit 5133a6d

Browse files
committed
accept asChild
1 parent d29c208 commit 5133a6d

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/components/ui/tag.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { cva, VariantProps } from "class-variance-authority"
2+
import { Slot } from "@radix-ui/react-slot"
23

34
import { cn } from "@/lib/utils/cn"
45

@@ -70,11 +71,14 @@ const tagVariants = cva(
7071

7172
export interface TagProps
7273
extends React.HTMLAttributes<HTMLDivElement>,
73-
VariantProps<typeof tagVariants> {}
74+
VariantProps<typeof tagVariants> {
75+
asChild?: boolean
76+
}
7477

75-
function Tag({ className, variant, status, ...props }: TagProps) {
78+
function Tag({ className, asChild, variant, status, ...props }: TagProps) {
79+
const Comp = asChild ? Slot : "div"
7680
return (
77-
<div
81+
<Comp
7882
className={cn(tagVariants({ variant, status }), className)}
7983
{...props}
8084
/>

0 commit comments

Comments
 (0)