Currently, I am delving into the world of styled components for a fresh project and exploring the theming capabilities it offers. I am finding it challenging to determine the best practice for adding multiple style properties to a single object, essentially creating a form of inheritance. My objective is as follows:
// Establish a set of styles for a specific component within the theme
// For example, every font includes a font-family, weight, size, etc
const theme = {
fonts: {
font-family: ...,
font-weight: ...,
font-size: ...,
}
}
// Within the styled component,
// include the multi-line theme, as well as component-specific styling
// and potentially override the theme styles
const Header = styled.span`
${props => props.theme.fonts};
text-decoration: underline;
...
`;
Currently, it seems necessary to pass the theme property to each style within the component. Is there a design pattern that could help streamline the code repetition evident in my example above?