Last active
October 29, 2020 18:06
-
-
Save jamiejohnsonkc/ba434c40c2de1f4faab749bf07df64d2 to your computer and use it in GitHub Desktop.
patterns for styling with emotion #emotion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import styled from '@emotion/styled' | |
//html element | |
const Button = styled.button` | |
color: turquoise; | |
` | |
//any component | |
const Fancy = styled(Basic)` | |
color: hotpink; | |
` | |
//object style any component/element | |
const Child = styled.div({ | |
color: 'red', | |
}) | |
const Parent = styled(Basic)` | |
{ | |
color: 'green'; | |
} | |
` | |
//props | |
const Button = styled.button` | |
color: ${(props) => (props.primary ? 'hotpink' : 'turquoise')}; | |
` | |
//another component | |
const Child = styled.div` | |
color: red; | |
` | |
const Parent = styled.div` | |
${Child} { | |
color: green; | |
} | |
` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment