最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - siblings CSS rules with React styled-componentsCSS modulesCSS-in-JS - Stack Overflow

programmeradmin1浏览0评论

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.

发布评论

评论列表(0)

  1. 暂无评论