Skip to content

Commit 91b3c4b

Browse files
committed
passing as
1 parent 36b3634 commit 91b3c4b

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

packages/react/src/Token/_TokenTextContainer.tsx

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,24 @@ import type React from 'react'
33
import classes from './_TokenTextContainer.module.css'
44
import {clsx} from 'clsx'
55

6-
const TokenTextContainer = ({children, id, ...props}: React.PropsWithChildren<Partial<TokenBaseProps>>) => {
6+
const TokenTextContainer = ({
7+
children,
8+
id,
9+
as: Component = 'span',
10+
...props
11+
}: React.PropsWithChildren<Partial<TokenBaseProps>>) => {
712
return (
8-
<span className={clsx(classes.TokenTextContainer)} id={id?.toString()} {...props}>
13+
<Component
14+
className={clsx(classes.TokenTextContainer)}
15+
id={id?.toString()}
16+
{...(Component === 'button'
17+
? (props as React.ButtonHTMLAttributes<HTMLButtonElement>)
18+
: Component === 'a'
19+
? (props as React.AnchorHTMLAttributes<HTMLAnchorElement>)
20+
: (props as React.HTMLAttributes<HTMLSpanElement>))}
21+
>
922
{children}
10-
</span>
23+
</Component>
1124
)
1225
}
1326

0 commit comments

Comments
 (0)