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

Provide Theme UI-specific "Global" component for global styles #2207

Closed
benface opened this issue Apr 21, 2022 · 2 comments · Fixed by #2385
Closed

Provide Theme UI-specific "Global" component for global styles #2207

benface opened this issue Apr 21, 2022 · 2 comments · Fixed by #2385
Labels
enhancement New feature or request

Comments

@benface
Copy link

benface commented Apr 21, 2022

Is your feature request related to a problem? Please describe.
Theme UI's documentation suggests to "use the Emotion Global component to add global CSS with theme-based values". That's great, but every once in a while, I forget that the syntax for its styles prop is different than what the sx prop allows, leading to wasted time and frustration. Two examples:

  1. You cannot use shorthand properties:
<Global
  styles={{
    'button': {
      p: 0, /* <-- should be `padding` */
    },
  }}
/>
  1. You cannot use design tokens directly:
<Global
  styles={{
    'button': {
      backgroundColor: 'coolGreen', /* <-- should be `theme.colors.coolGreen` */
    },
  }}
/>

Describe the solution you'd like
It would be really awesome if Theme UI provided its own Global component (probably in a separate package, e.g. @theme-ui/global), that made the above two examples work out of the box.

Describe alternatives you've considered
None.

Additional context
Thank you. 🙏

@hasparus hasparus added the enhancement New feature or request label Apr 22, 2022
@hasparus
Copy link
Member

Hey @benface 👋

It would definitely be a great addition. I usually advised people to add stuff to a global CSS file or use a reset, but there are some use cases that just ask for a component similar to Emotion's Global. The solution you've described looks great.

Thank you for the issue 🙏

@benface
Copy link
Author

benface commented Apr 22, 2022

Thank you @hasparus!

I forgot to mention that I would expect the array syntax for responsive values to work as well (3rd example):

<Global
  styles={{
    'button': {
      padding: ['16px', '32px'], /* <-- should be `padding: '16px'` + `@media (min-width: ...) { padding: '32px' }` */
    },
  }}
/>

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

Successfully merging a pull request may close this issue.

2 participants