Skip to content

Using the sibling selector together with props #2402

Answered by Andarist
ronderksen asked this question in Q&A
Discussion options

You must be logged in to vote

The usual answer is - don't do this. Don't introduce such contextual styles.

However, if you really want this you can do this (when using our Babel plugin):

 const Banner = Styled.div`
  ${({ type }) => css`
    ${getColorsForType(type)}
    width: 100%;
    display: inline-block;
 
    ${() => Banner} + ${() => Banner} {
       margin-left: 16px;
     }
  `}
`

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@ronderksen
Comment options

@Andarist
Comment options

Answer selected by ronderksen
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants