RFC: Component Selector
See original GitHub issueI was chatting to @markdalgleish at Reactive conf and he had this great idea to implement a other-styled-component-selector.
The API would look like this:
const Button = styled.button`some: styles;`
const Box = styled.box`
> ${Button} {
// A button component nested within a box will have these styles
other: styles;
}
`
This would allow you to override styles of children, and from children react to parents, too! What do you think?
Issue Analytics
- State:
- Created 7 years ago
- Reactions:70
- Comments:25 (12 by maintainers)
Top Results From Across the Web
CSS Definition for a LWC Component - RFCs
Implementations should not rely on or use the selectors generated by the Lightning Web Components compiler. This is an implementation detail of Lightning...
Read more >RFC 7408: Forwarding and Control Element Separation ...
Code Components extracted from this document must include Simplified BSD ... <xsd:key name="structComponentID1"> <xsd:selector xpath="lfb:component"/> ...
Read more >React RFC: Context Selectors : r/reactjs - Reddit
I'm building react-complex-tree, an unopinionated tree component for react, and recently released a new version! media poster.
Read more >Selectors Level 4 - W3C
Selectors have been optimized for use with HTML and XML, and are designed to be usable in performance-critical code. They are a core...
Read more >RFC 5474 - A Framework for Packet Selection and Reporting
A Framework for Packet Selection and Reporting (RFC 5474, March 2009. ... This framework details the components of this architecture, then describes some ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It’s not something we will encourage, but that doesn’t mean the possibility shouldn’t be there. The same thing applies to nesting, I try to avoid nesting as much as possible and we could’ve made it impossible in
styled-components
, but it does have it fringe use cases and we want to cover all the ground.I am not convinced that styling children from the parent is something to encourage.
In any case, when it is unavoidable, like when you are making a layout component based on flexbox, I do something like
The child selectors are also very useful for these purposes.