Subscribe on changes!

CSS variable binding is not intuitive, and the scope of common attributes and variable attributes in the same CSS class is inconsistent

avatar
Dec 4th 2023

Vue version

3.3.8

Link to minimal reproduction

https://play.vuejs.org/#eNp9Uk1P4zAQ/SsjX1q0bLKIWzcg7SIk4AAIEFx8Kck0NTh25JmUoij/nbGbQiU+5Is97834zbzp1b+2zVYdqpkqqAymZSDkrj3WzjStDwxnaK1/8MFWsAi+gUmWn/gmJU20K/JNlvDlwdi0ds4oLwAolgdQ2jnRkVaMxFod3xtG+AX3HRb58mCk7fzQUC3kD5ZWkAuryHcqa6f2FVPp3cLU2RN5J+L7WEqrUpQZi+GqZeMdaTWDhERsLr+8XKQYhw73t/FyieXzF/EnWseYVtcBCcNKxLxjPA81SkMRPr29xLXc38HGV50V9g/gDZK3XdS4of3vXCWyd3hJ7XmywLj6jk7XjI62TUWhkTkkvlZiRjTlu9Y/5B5mhylPu0GmuDXye/d7CLiAYbR+43k8Mn1iKL31AY4iZzqpA6Kb7EW0woVxeB18S9MkQnydwS0HaUUUD4m0LdE5Hkv8kfgPC/XFPvV9LA3DMK7Tp1UpiF9tvGYxYzORpHoGq9+PxlXT9Nr7K6rS5yNdDW8+ZQv5

Steps to reproduce

CSS variables bound in subcomponents have no effect at the parent level, but styles without scoped are valid except for variable binding fields

What is expected?

When scoped is not used, variables maintain the same influence range as other regular styles

What is actually happening?

The same type of named variable in the parent component is not effective now

System Info

No response

Any additional comments?

No response

avatar
Dec 4th 2023

This is how it's designed.

The actual value will be compiled into a hashed CSS custom property, so the CSS is still static. The custom property will be applied to the component's root element via inline styles and reactively updated if the source value changes.

https://vuejs.org/api/sfc-css-features.html#v-bind-in-css