-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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 we allow creating your own CSS variables via Global Styles? #25393
Comments
cc for thoughts: @aristath @kjellr as you were using this, @jorgefilipecosta @youknowriad @mtias |
An alternative could be to add presets for the style properties we support that don't have presets yet (line-height (example), padding example) but don't surface them visually, as that resulted problematic in the previous attempts we tried. Would this be useful/enough? Food for thought: the examples I saw were fundamentally used for typography, where you need a mix of font-size, line-height, etc to get good results. If people wanted to create a typographic scale (font base + scale) a system to create their own CSS variables would be handy, and having a curated list of things will prove not enough. |
Agreed. It would be really convenient for theme-authors to have a single source of truth for all their default vars, and the |
Themes are inevitably going to want to add additional variables, and I agree with @aristath that they should be declared in a single document. Putting them in some sort of "custom" section would be totally fine, and would make it clear that they aren't going to be surfaced in the UI somewhere. |
We could also add a Custom CSS section to the global styles area. |
Context (slack thread).
Before #25301 the theme.json shape was like this:
The CSS variables we generate for presets follow this pattern
--wp--preset--{category}--{slug}
(ex:--wp--preset--color--nice-blue
). The old mechanism took all categories withinpresets
and created the proper variables without checking whether it was one of the three categories we had (color, gradient, font size) --- this was a bug. However, people used this to add their own things, likeline-height
presets (example 1, example 2).After #25301 this is no longer possible, as we keep a curated list of presets. This is the current shape, for reference:
People raised that they were missing some CSS variables and proposed to add some back.
Given that
theme.json
pushes theme authors to write the less CSS possible (ideally, none), this bears the question: should we formalize the old mechanism by which it's possible to generate theme-only CSS variables that can be used in the styles?The text was updated successfully, but these errors were encountered: