styled-jsx - Behavior clarification: Should css.resolve
accept top level CSS declarations?
#6065
Unanswered
smoores-dev
asked this question in
Help
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello!! I'm working on a project using styled-jsx with next.js. At some point I added a
css.resolve
call that looks like this:And then use it in the following JSX:
This works exactly as I expected it to; the
<Burger>
component applies itsclassName
prop to its top level DOM element, which then gets the declarations defined above.But... the docs don't ever actually show an example like this. Instead, they have examples that define an entire ruleset, which requires knowing what the DOM within the child component looks like:
Again, the code that I'm currently using works! My question is: Is that purely incidental?? Is this explicitly supported behavior, or does it just happen to work now and might break in the future? If it's supported on purpose, could it be documented? Personally I have a strong preference for styling child components this way, as it doesn't require breaking encapsulation the way the documented examples do (that is, I don't need to know anything about the internal structure of the component in order to position it or give it margins).
Beta Was this translation helpful? Give feedback.
All reactions