Skip to main content

Crate use_css

Crate use_css 

Source
Expand description

§use-web-css

Small CSS utility primitives for RustUse.

§Experimental

use-web-css is experimental while the use-web workspace remains below 0.3.0. Expect small API adjustments during the first release wave.

The published package name is use-web-css so it avoids the existing crates.io collision on use-css, while the Rust library target remains use_css.

§Example

use use_css::{extract_css_declarations, is_css_color_value, minify_css_basic};

let declarations = extract_css_declarations(".card { color: red; margin-top: 1rem; }");

assert_eq!(declarations.len(), 2);
assert!(is_css_color_value("#ff00aa"));
assert_eq!(minify_css_basic(".card { color: red; }"), ".card{color:red;}");

§Scope

  • Lightweight CSS detection and declaration parsing.
  • Small helpers for identifiers, custom properties, colors, and lengths.
  • Comment stripping and basic minification.

§Non-goals

  • Full CSS parsing.
  • Cascade engines.
  • Browser style engines.
  • CSS-in-JS utilities.
  • JavaScript tooling.

§License

Licensed under either of the following, at your option:

  • Apache License, Version 2.0
  • MIT license

Structs§

CssDeclaration
A lightweight CSS declaration.
CssRule
A lightweight CSS rule.

Functions§

extract_css_declarations
Extracts declarations from a CSS block or declaration list.
is_css_color_value
Returns true when the input looks like a common CSS color value.
is_css_custom_property
Returns true when the input looks like a CSS custom property.
is_css_identifier
Returns true when the input looks like a CSS identifier.
is_css_length_value
Returns true when the input looks like a common CSS length value.
looks_like_css
Returns true when the input looks like CSS markup or a declaration.
minify_css_basic
Performs a small whitespace-oriented CSS minification pass.
normalize_css_property
Normalizes a CSS property to lowercase ASCII.
split_css_declaration
Splits a property: value declaration.
strip_css_comments
Removes CSS comments from the input.