Skip to content

Passing CSS props to functional component #2631

Answered by srmagura
carldegs asked this question in Q&A
Discussion options

You must be logged in to vote

Hey @carldegs, the css prop is "magic" so it won't get passed down to Component like a normal prop. You can review this section of our documentation.

This is what you want:

const Component = ({ className, children }) => <div css={{ 'background': 'blue' }} className={className}>{children}</div>

className will include the Emotion-generated class from the css prop.

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@carldegs
Comment options

Comment options

You must be logged in to vote
1 reply
@carldegs
Comment options

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