admin管理员组

文章数量:1315362

How to you translate rules involving siblings selectors with styled-ponents ? (I think it also concerns other flavors of styling through generated class names)

const Pane = styled.div`
  & > .subItem + .subItem {
    margin-top:10px;
  }
`

How to you translate rules involving siblings selectors with styled-ponents ? (I think it also concerns other flavors of styling through generated class names)

const Pane = styled.div`
  & > .subItem + .subItem {
    margin-top:10px;
  }
`
Share Improve this question edited Nov 30, 2016 at 7:50 mxstbr 11.5k4 gold badges41 silver badges38 bronze badges asked Nov 26, 2016 at 20:18 sylvainsylvain 1,9812 gold badges20 silver badges34 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 8

The code you posted totally works if you have static class names on children and/or siblings!

We don't currently support selecting other styled ponents with their generated class names, but we will very very soon! (probably this week or next week)

This is the API we're looking towards adding:

const StyledDiv = styled.div``

// All StyledDiv's directly inside a Pane will have blue text
const Pane = styled.div`
  & > ${StyledDiv} {
    color: blue;
  }
`

Follow this issue and the linked PR to be notified when it lands.

本文标签: javascriptsiblings CSS rules with React styledcomponentsCSS modulesCSSinJSStack Overflow