Closed wh5938316 closed 1 week ago
I am wondering if there are any plans to add a withComponent interface or an as prop similar to EmotionJS. This feature would be incredibly useful for scenarios where we need to specify the HTML tag used for rendering a component.
https://emotion.sh/docs/styled#change-the-rendered-tag-using-withcomponent https://styled-components.com/docs/api#as-polymorphic-prop
const Component = styled.div` color: red; `; render( <Component as="button" onClick={() => alert('It works!')} > Hello World! </Component> )
Search keywords: withComponent, as Prop, EmotionJS
This already works right now.
Summary
I am wondering if there are any plans to add a withComponent interface or an as prop similar to EmotionJS. This feature would be incredibly useful for scenarios where we need to specify the HTML tag used for rendering a component.
Examples
https://emotion.sh/docs/styled#change-the-rendered-tag-using-withcomponent https://styled-components.com/docs/api#as-polymorphic-prop
Motivation
Search keywords: withComponent, as Prop, EmotionJS