Expand description
§CSS Variables Module
This module provides support for CSS custom properties (CSS variables) in the Mew CSS library. CSS variables allow you to define reusable values that can be referenced throughout your styles.
§Usage
There are two main ways to use CSS variables:
- Defining variables - Use the
set_varmethod onStyleto define a variable - Using variables - Use the
varfunction to create a reference to a variable
§Example
use mew_css::{style, var};
use mew_css::values::Color;
// Define CSS variables
let root_style = style()
.set_var("primary-color", "#3366ff")
.set_var("spacing", "1rem")
.apply();
// Use CSS variables
let button_style = style()
.color(var("primary-color").into())
.padding(var("spacing").into())
.apply();Structs§
- CssVar
- Represents a reference to a CSS custom property (CSS variable).
Functions§
- var
- Creates a new CSS variable reference.