9

I write styled components like in react-native, as a js object:

const SectionTitle = styled.div({
 fontSize: '25px',
 display: 'flex',
})

Is it possible to use media queries with the above object style?

asked Nov 23, 2018 at 8:55

1 Answer 1

13

Yes, this is possible. You just need to wrap your object keys with quotes to form a string from a media query rule.

For example:

const SectionTitle = styled.div({
 fontSize: '25px',
 display: 'flex',
 '@media(min-width: 788px)': {
 fontSize: '40px'
 }
})
answered Nov 23, 2018 at 9:04
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.