Common styles merged into variants? #1565
Replies: 2 comments 3 replies
-
Yep, this is absolutely a weakness of the Theme UI API right now. There is no great way to do this, though if you've split your theme into separate objects/files, spreading an object into each of the e.g. button variants is a decent option. |
Beta Was this translation helpful? Give feedback.
-
Having worked on this a bit locally I came up with a couple alternatives. One is to allow
This would match how emotion does "composition": https://emotion.sh/docs/composition Alternatively the theme object itself could support "extending":
That's nice because it lets the theme-writer determine how styles are shared which is important for us because we accept the theme from the consumers (of our library) who don't control the JSX. But I don't know if that is contrary to the philosophy of the theme system. This is what we've done locally w/ a modified theme-ui and it seems to work pretty well for our limited use-case. We don't support multiple levels of |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm trying to figure out the best way to have common styles that the variants build on. For example in the docs (https://theme-ui.com/theme-spec#variants) there is an example of button variants:
But is there a way to specify common styles for all button variants, like if all buttons should have a
borderRadius
? Looking at howBox
works in the source it doesn't appear that this is currently possible. I was able to simulate it by reimplementingBox
and just changing thevariant
loading code to:Perhaps this is not an expected usage of theme-ui or am I missing the correct way to accomplish "common" styles?
Beta Was this translation helpful? Give feedback.
All reactions