Skip to content

Instantly share code, notes, and snippets.

@jamiejohnsonkc
Last active October 29, 2020 18:06
Show Gist options
  • Save jamiejohnsonkc/ba434c40c2de1f4faab749bf07df64d2 to your computer and use it in GitHub Desktop.
Save jamiejohnsonkc/ba434c40c2de1f4faab749bf07df64d2 to your computer and use it in GitHub Desktop.
patterns for styling with emotion #emotion
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