-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Does this work!? https://www.christianvm.dev/blog/react-as-prop
type PolymorphicProps<E extends React.ElementType> = React.PropsWithChildren<
React.ComponentPropsWithoutRef<E> & {
as?: E
}
>
type TypographyProps<T extends React.ElementType> = PolymorphicProps<T> & {
color?: string
}
export function Typography<T extends React.ElementType = 'p'>({
as,
color,
...props
}: TypographyProps<T>) {
const Component = as || 'p'
console.log(color)
return <Component {...props} />
}Metadata
Metadata
Assignees
Labels
No labels