Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should colors.background, text etc automatically apply to Styled export? #156

Closed
erikdstock opened this issue Jul 4, 2019 · 3 comments
Closed

Comments

@erikdstock
Copy link

Hi, I'm trying to understand how Styled.{components} work outside the context of an MDXProvider. I'm imagining that a minimal theme definition will automatically apply to Styled elements, so one could replace all instances of <p>some text</p> with <Styled.p ... and see the text color as theme.colors.text but this doesn't seem to be the case.

I guess my 2 questions are:

  • is the theme.styles object required for any Styled components to have a default style, ie not require sx={{color: "text"}} ?
  • if so, are the properties color.{background,text,etc} actually required or just recommendations?

Happy to close this or convert it into an issue/PR to update docs if it helps.

@jxnblk
Copy link
Member

jxnblk commented Jul 4, 2019

The Styled components will pick up values from theme.styles so that theme.styles.p will apply to <Styled.p />. You can also use the sx prop with Styled components if you've set the custom pragma in a module. The colors and other raw values don't apply automatically to any component other than the ColorMode component, which will use colors.text and colors.background on the body element

To try to answer, theme.styles isn't required, but that's where the Styled components get default styles, and the colors object shape is mostly a recommendation for interoperability/portability, but text and background are tied to the color modes feature

@erikdstock
Copy link
Author

Thank you, extremely helpful!

@jxnblk
Copy link
Member

jxnblk commented Jul 5, 2019

Closing this for now, but feel free to open another issue or PR if you have a more specific example of how to make the docs around this clearer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants