| Crates.io | csscascade |
| lib.rs | csscascade |
| version | 0.0.0 |
| created_at | 2025-11-24 23:47:42.072977+00 |
| updated_at | 2025-11-24 23:47:42.072977+00 |
| description | A modern, Rust-native CSS Cascade & Style Resolution Engine designed for building browser-like rendering pipelines |
| homepage | https://grida.co |
| repository | https://github.com/gridaco/grida |
| max_upload_size | |
| id | 1948922 |
| size | 45,038 |
A modern, Rust-native CSS Cascade & Style Resolution Engine designed for building browser‑like rendering pipelines. csscascade takes an HTML (and later SVG) DOM tree and produces a style-resolved static tree ready for layout and painting.
This crate implements the hardest and most fundamental part of a rendering engine: the transformation from loosely-typed DOM nodes + CSS rules into a fully computed, normalized, strongly-typed tree.
Future support for SVG is planned (HTML + SVG share >90% of style logic).
Accepts a DOM-like tree (any structure implementing the crate's DOM traits).
A new tree where every node has its final computed style attached. This tree contains:
csscascade does not perform layout.
It outputs a static, fully resolved element tree specifically designed to be fed into your layout engine (block/inline/flex/grid/etc.).
Since the style is computed and normalized, the next stages can be:
Rendering HTML and SVG is deceptively hard. Even before layout and paint, a renderer must:
None of these steps are specific to a browser — they are fundamental requirements for any engine that wants to render HTML or SVG, whether for graphics, documents, UI, or design tools.
The goal of csscascade is not to help you build a browser. Instead, it’s designed for developers building:
It handles the universally hard parts (CSS cascade, style normalization, static tree production) so your engine can focus on layout and painting, not CSS correctness.
This crate is specifically for people building a static renderer — not a real DOM, not a browser, not an interactive layout engine.
If you:
…then csscascade is designed for you.
For example:
If you need:
…this crate intentionally does not target that use case.
csscascade outputs a style‑resolved static tree — every node has fully computed CSS applied, ready for layout.
A future feature flag will allow the crate to output a layout‑computed, render‑ready tree, so you can plug it directly into your painter.
Input DOM Tree (HTML / XML / SVG)
↓
csscascade (this crate)
↓
Style‑Resolved Static Tree
↓
Layout Engine
↓
Painting
Each node in the output tree includes:
This tree is static and does not update unless the DOM or styles change.
var()) resolutionThese are intentionally separate stages.
use csscascade::{Cascade, StyledTree};
use your_dom_library::Document;
let dom: Document = parse_html("<div class=\"title\">Hello</div>");
let css = "
.title {
font-size: 24px;
font-weight: bold;
}
";
let cascade = Cascade::new(css);
let styled: StyledTree = cascade.apply(&dom);
// Pass styled to your layout engine
layout_engine.layout(&styled);
MIT or Apache-2.0 (TBD)
Contributions are welcome!
If you're building a rendering engine, layout system, or visualization tool, this crate aims to be the foundational CSS cascade layer you can rely on.
⚠️ Early development — API may change as SVG support and additional CSS features are added.