The behavior of theme.json in child theme #69431
Closed
namgpuglisi
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello devs, I created a child theme for a custom FSE theme developed by me and the team where I work.
In the parent theme, we heavily use the theme.json, then I tried to override a part of it in the child theme.
For example, I changed some colors in our palette to see the result in the frontend, but the new CSS variables created from the child theme were overwritten by the variables created by the parent theme.
The child theme runs before the parent, so the CSS rules are printed earlier in the DOM compared to the rules of the parent theme.
Is this the default behavior to be expected?
In my mind, editing theme.json in the child theme should mean "overwrite this option."
I could resolve the problem with a filter or by using the styles folder to create variations of the theme.json, but I don't agree with the reported behavior and I want to hear your experiences/opinions. Maybe I'm off track.
Edit: i close the discussion because i found the problem. The rules more specific, in this case relative to the core/group block, must be overwrite in the child theme to work properly. Then the behavior of the child theme is in line with the expectations !
Beta Was this translation helpful? Give feedback.
All reactions