Can't pass down styled props to an extended styled system + rebass component
See original GitHub issueI’m creating a Position component like so:
import styled from 'styled-components'
import { position } from 'styled-system'
import { Box as Base } from 'rebass/styled-components'
const Position = styled(({ position, ...props }) => <Base {...props} />)`
${position}
`
export default Position
I’m expecting to be able to use it like so after importing into another file:
const Header = styled(Position)` color: red `;
<Header
as="header"
mb={4} // Box styled props
pt={3} // Box styled props
position="sticky"
top={0}
left={'auto'}
right={'auto'}
zIndex={100}
>
Do I need to be utilizing forwardRef
? Is there a way to pass down both Box
props and Position
props from an extended component?
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Extending - Rebass
To extend a component, pass props through and define custom styles in the sx prop. import React from 'react'. import { Box }...
Read more >@rebass/components - npm
@rebass/components automatically adds prop type definitions and removes style props from the underlying HTML element. See the styled-system docs ...
Read more >Chakra UI: Sleek UI Components for React - KnowledgeHut
1. Style Props. Because Chakra UI is based on stylized systems, any component styles can be overridden or extended via props. As a...
Read more >Limitations of Chakra UI - Ryosuke
It's similar and more feature complete to other Styled System-based UI libraries like Rebass. I've been a huge fan of utility style props...
Read more >Understanding The Styled System - Anvil
This power extends to any imaginable CSS out there; you can pass hex values, rgba values, hsl values, etc. to our backgroundColor prop...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
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
At first glance, this looks like it should work. Can you provide a codesandbox link with a reproduction?
No idea about the community in general, I mainly just prefer emotion’s css prop instead of creating one shot components for every styled div. Plus emotion seems to be react concurrent mode ready, but that shouldn’t be a concern for now I think.