Expand description
Parser + AST for a CSS subset used to drive declarative UI styling.
Toolkit-agnostic — produces a Stylesheet of Rules plus a resolve()
step that yields the property bag for a single node. Pair with an
adapter crate (e.g. hjkl-css-floem) to map onto a specific UI
framework’s style builder.
Supported:
- Type selectors (
label,row), class selectors (.prompt), pseudo-class selectors (:hover,:focus,:active,:disabled,:selected), and combinations of the three on the same simple selector. - Compound selectors with descendant (
), child (>), adjacent-sibling (+), and general-sibling (~) combinators. - Properties:
color,background-color,padding,margin,width,height,display,flex-direction,flex-grow,flex-shrink,flex-basis,align-items,justify-content,gap,row-gap,column-gap,border,border-{top,right,bottom,left},border-width,border-color,border-radius,outline,font-family,font-size,font-weight,font-style,text-align,line-height. - Values: hex /
rgb()/rgba()/ named colors (CSS Level 1 + extras), lengths inpx/%/ unitless (treated as px), keywords,auto, unitless numbers, font-family lists, border shorthands.
Re-exports§
pub use ast::Combinator;pub use ast::Declaration;pub use ast::Node;pub use ast::PseudoClass;pub use ast::Rule;pub use ast::Selector;pub use ast::SimpleSelector;pub use ast::Stylesheet;pub use error::ParseError;pub use parse::parse;pub use resolve::ResolvedStyle;pub use value::Color;pub use value::Length;pub use value::SideValue;pub use value::Value;pub use value::expand_side_set;pub use value::expand_sides;
Modules§
- ast
- Parsed stylesheet representation. Each rule pairs one
Selector(a chain ofSimpleSelectors joined byCombinators) with one declaration block. - error
- parse
- Convert a CSS-subset string to a
Stylesheet. Backed bycssparser’s tokenizer +StyleSheetParser. Compound selectors with descendant (), child (>), adjacent-sibling (+), and general-sibling (~) combinators are supported. - resolve
- Stylesheet → declaration list for a given (target, ancestors, state).
- value
- Property values. v1 covers the handful needed by phase-1 properties (background-color, color, padding, margin, width, height); phase-2 adds Auto, Number, FontFamilyList, Border, and SideSet for mixed length/auto shorthands.