Skip to content

Dynamic components

Dynamic components mean components that generate styles based on their props. Similar to the concept of React's view as a function of its state, here the styles are a function of its props.

module Dynamic = %styled.div(
(~color, ~background) => j`
color: $(color);
background-color: $(background);
<Dynamic color="#EB5757" background="#516CF0">

Useful to define a React component with their API exposed as props. Here are applied the same rules as Interpolation.