Semantics
By default, components generated by the library (Box
, Composition
, and area components) render a <div>
element, which may not be a valid HTML element in some use cases.
You can provide a custom HTML element or a React component to render instead of the default one by using polymorphic prop styled-components
feature.
See Polymorphic prop API in styled components' documentation.
Using HTML element
To render a different HTML element provide its name as a value of the as
prop of any component exported or generated by the library:
Using React component
To render a custom React component provide its reference as a value to the as
prop.
You must spread the props in your custom component to propagate class names generated by styled-components
.
Custom areas components
Polymorphic prop can be used on the area components generated by Composition
.
Last updated