Closed (fixed)
Project:
Display Builder
Version:
1.0.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
3 Dec 2025 at 15:42 UTC
Updated:
11 Nov 2026 at 07:46 UTC
Jump to comment: Most recent
Comments
Comment #2
pdureau commentedIn UI Skins 1.x, there is no differences between "global CSS variables" and "component CSS variables".
In UI Skins 2.x, we will have su h difference thanks to the work on Core's #3531854: Add a Design Tokens & CSS variables API but it will work the opposite way:
Comment #3
pdureau commentedComment #4
pdureau commentedBeta4 has already been released.
Comment #5
mogtofu33 commentedComment #6
mogtofu33 commentedComment #7
mogtofu33 commentedUpdated the issue summary to keep this issue on its original ask: scoped variables for the selected component. Global tokens moved to #3624054: Global design tokens panel, with live preview in the builder, with the new core Design Tokens API in mind.
About #3561282-2: Design tokens panel: keep existing inline styles, list overrides in the summary: no need to wait for a new UI Skins version. The scopes declared in
default_valuesalready tell component variables apart from global ones.Comment #8
pdureau commentedI am having a look on the updated issue summary.
CSS variables
(just a reminder, for the ones not familiar with the concept which would want to help with the ticket)
When used, a CSS variable is the combination of 3 parts:
When used from UI Skins'
/admin/appearance/css-variables, the CSS variables are printed in page body like that:Display Builder tokens panel does that a but differently, it uses an inline
styleattributeThe scope is implicit, it is the HTML node where the
styleattribute is added.In theory, there is no "global" or "local" design tokens, the scope make them global or local. For example, we don't expect
global-primary-color,card-primary-color,button-primary-color... We only expectprimary-color, which can be scoped to:root,.card,.btn...Bootstrap is the problem here
Bootstrap 5 did the mistake to convert all their internal Sass Variables to CSS Variables, and we now have a mess.
It is even worth than hardcoding the scope in token names (
card-primary-color,button-primary-color...). They hardcode the token name in the scope:It makes CSS variables nearly unusable in Bootstrap projects. It was already discussed in #3389752: UI Skins: Reduce the number of CSS variables but we didn't find a solution.
So, it is better to not take Bootstrap as an example when we try to improve the
tokenpanel.What can we do?
I agree it is a fragile mechanism, but there was an intent here: a global variable (so, with
:rootscope) will be more prone to be applicable anywhere than a variable without the global scope.In other words, I trust
:root { --color-primary: red }more to be applicable to.cardscope than.fab { --degree: 0 }.🤔 However, an alternative proposal is always welcomed.
That's the purpose of scoping: a global list, a local override.
So, the title of the ticket ("Design tokens panel: show only variables scoped to the selected component") is not something we would want to do.
It is also not something we could really do if we would want, because we don't know what would be the scope of a component. We can guess it, but it will be a fragile and risky guess. For example:
buttonbtnbuttonbuttonbuttonbtnbuttonfr-btnbuttonmdc-buttonbuttonmzp-c-button❌ So, I would vise to not go to this direction. "Normal" scoping already works kind of well outside of Boottsrap.
👌 Let's fix that.
👌 Let's fix that.
So, I would advise to focus on the
alterElement()andThirdPartySettingsInterfacechanges.Don't use the ticket title as the commit message if we don't show only variables scoped to the selected component ;)
Comment #9
pdureau commentedComment #11
pdureau commentedProposal pushed.
Implementation
The "ThirdPartySettingsInterface and summary" is straightforward.
The "alterElement() and #attributes['style']" part is more complex than expected:
alterElement()adds a step to the component's #pre_render list, just before theui_patternsmerge (ComponentElementAlter). That step writes everything into#props['attributes']['style'], in this order: the element's own#attributesstyle, the prop's style, then the tokens.This would be better fixed on UI Patterns side according to Claude LLM:
Tests
Tested with UI Suite DaisyUI theme and with the Design Tokens panel activated on the profile.
ThirdPartySettingsInterface and summary:
alterElement() and #attributes['style']:
style="foo: bar"to theattributespropstyle="foo: bar; --color-success: yellow;"Builder panelstyle="foo: bar;"Builder panelThis was also the opportunity to rename the panel from "Design tokens (CSS variables)" to "Design tokens"
What's next?
Review the changes.
And it is not too late to propose an alternative to only showing global CSS variables in the panel 😉
Comment #12
csakiistvanComment #13
csakiistvan✅ Tested and works — on a component whose attributes prop sets
style="foo: bar", a Design tokens value was saved but missing from the rendered element; after applying MR !523 and rebuilding caches, the element rendersstyle="foo: bar; --card-accent: #aa7941;". The token no longer gets lost next to an attributes prop style.Notes
foo: bar: the attributes prop style wins the merge.ui_patterns.component_element_alter:alteris not in the element's#pre_render,alterElement()falls back to#attributesand the token is lost again without notice; no test covers that path.getSummary()skips variables without a definition, butalterElement()still renders them, and an empty value renders as an empty declaration (--var:).Comment #14
pdureau commentedInteresting. I will address that and move back to RTBC.
Comment #15
pdureau commentedMoved back to "Needs Review" instead of RTBC, because this little change was the opportunity of sharing the same filtering rules between
::alterElement()and::getSummary(), and it "forced" us to alter one phpunit test.Comment #16
csakiistvan✅ Tested and works — ran the same five cases through
alterElement()(on an element withstyle="foo: bar;") andgetSummary(), before and after da78176: empty, blank and unknown values no longer render, and the rendered variables now match the summary. RTBC from my side.Comment #17
pdureau commentedComment #18
mogtofu33 commentedComment #20
mogtofu33 commentedComment #22
pdureau commentedShipped in beta10 release.