Answer the question
In order to leave comments, you need to log in
How to implement class mixes in styled-components?
In a project I have the following structure (mix) which I use to indent certain blocks:
.mix-block {
&__title {
margin-bottom: 10px;
}
&__subtitle {
margin-bottom: 5px;
}
}
<div class="news-article mix-block">
<div class="news-article__title mix-block__title">some title</div>
<div class="news-article__subtitle mix-block__subtitle">some subtitle</div>
<div class="news-article__desc">some desc</div>
</div>
const NewsArticle__Title = styled(MixBlock)`
/* some custom styles */
`
Answer the question
In order to leave comments, you need to log in
Those. I create stylized blocks NewsArticle, NewsArticle__Title, etc., I create blocks MixBlock__Title, MixBlockSubtitle somewhere separately in a more "global" area and write styles according to the following principle?
const MixBlock = styled.div`
/* some custom styles */
`;
const NewsArticle__Title = styled(MixBlock)`
/* some custom styles */
`;
const MixStyles = `
...
`;
const NewsArticle__Title = styled.div`
${MixStyles}
`
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question