Do not pollute root namespace and assign variables locally only #674
-
|
Hello, is it possible to create vars that are locally scoped, and not assigned to :root? I use a design system with a lot of components, and the root namespace is polluted by hundreds of vars that are either not used, or always overwritten with component themes. Thanks. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
root.mov |
Beta Was this translation helpful? Give feedback.
-
|
You can set the values in a export const myVars = stylex.defineVars({
primary: null as null | string,
secondary: null as null | string,
});Now the variables will not be defined for |
Beta Was this translation helpful? Give feedback.
You can set the values in a
defineVarscall tonulland then only define their values withcreateTheme. You will need to use more type annotations though.Now the variables will not be defined for
:root.