Last updated on February 21, 2026
vars() & useUnstableNativeVariable()
vars()
vars is a function that takes a dictionary of CSS variables and returns a style object. When applied to a component's style prop, the variables flow down the component tree, just like CSS custom properties.
Variables set with vars() can be consumed by any descendant component using var() in their class names or CSS.
Combining with styles
vars() returns a style object, so you can spread it alongside other styles:
VariableContextProvider
VariableContextProvider sets CSS variables via React context rather than the style prop. This is useful when you need variables available to components that aren't direct style descendants:
useUnstableNativeVariable()
This API is unstable and may change in future releases.
useUnstableNativeVariable reads the current value of a CSS variable from the nearest variable context. This is useful for cases where you need a variable value in JavaScript rather than in a class name: