Answer the question
In order to leave comments, you need to log in
How to dynamically update values in the styled-components theme?
In projects, I quite often use a css variable in the spirit of --space-unit, to which I set the following styles:
--space-unit: 10px;
@media (max-width: 991px) {
--space-unit: 7px;
}
@media (max-width: 991px) {
--space-unit: 5px;
}
margin-bottom: calc(20 * var(--space-unit))
const theme = {spaceUnit: 10}
const theme = {spaceUnit: 'var(--space-unit')}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question