A CSS variable, also called a CSS custom property, gives a value a reusable name. In a web component, it can let someone change an internal style without editing the component’s stylesheet. section 3.8.2
Let users choose a component’s text color
Inside a component’s styles, write `p { color: var(--hello-color, purple); }`. The `var()` function uses `--hello-color` when it is defined and `purple` otherwise. Outside the component, `hello-world { --hello-color: red; }` sets the color for that element; `:root { --hello-color: red; }` is another option. Custom properties defined outside a shadow DOM are inherited inside it. section 3.8.2
Two practical uses build on that pattern:
- Themes: a collection of custom properties can act as design tokens. Changing token values in one place adjusts styling across an app; Web Awesome themes use this approach. section 2.4
- Reactive styling: a component can update `--font-size` on a paragraph’s `style` attribute while its stylesheet uses `font-size: var(--font-size)`. Lit, Stencil, and FAST examples connect this to a range slider that changes text size. section 5.7 section 6.8
Use a custom property when a style should be configurable from outside a component or driven by a changing component property. Document the properties a component exposes, especially when it offers more than one. section 3.8.2 section 5.7






