Expand description

Common CSS values used across many properties.

Each value provides parsing and serialization support using the Parse and ToCss traits. In addition, many values support ways of manipulating them, including converting between representations and units, generating fallbacks for legacy browsers, minifying them, etc.


This example shows how you could parse a CSS color value, convert it to RGB, and re-serialize it. Similar patterns for parsing and serializing are possible across all value types.

use parcel_css::{
  traits::{Parse, ToCss},

let color = CssColor::parse_string("lch(50% 75 0)").unwrap();
let rgb = color.to_rgb();
assert_eq!(rgb.to_css_string(PrinterOptions::default()).unwrap(), "#e1157b");

If you have a cssparser::Parser already, you can also use the parse and to_css methods instead, rather than parsing from a string.


CSS alpha values, used to represent opacity.

CSS angle values.

Mathematical calculation functions and expressions.

CSS color values.

CSS easing functions.

CSS gradient values.

CSS identifiers.

CSS image values.

CSS length values.

CSS number values.

CSS percentage values.

CSS position values.

CSS ratio values.

Generic values for four sided properties.

CSS resolution values.

CSS shape values for masking and clipping.

Generic values for two component properties.

Types used to represent strings.

CSS syntax strings

CSS time values.

CSS url() values.