cssbox-core 0.1.0

Standalone CSS layout engine — core algorithms
Documentation
  • Coverage
  • 35.5%
    153 out of 431 items documented1 out of 154 items with examples
  • Size
  • Source code size: 169.7 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 19.09 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 15s Average build duration of successful builds.
  • all releases: 15s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • npow/cssbox
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • npow

cssbox-core — A standalone CSS layout engine.

This crate implements CSS layout algorithms: block, inline, float, positioning, flexbox, grid, and table. It takes a tree of styled nodes as input and produces computed positions and sizes as output.

Usage

use cssbox_core::tree::BoxTreeBuilder;
use cssbox_core::style::ComputedStyle;
use cssbox_core::geometry::Size;
use cssbox_core::layout::{compute_layout, FixedWidthTextMeasure};

let mut builder = BoxTreeBuilder::new();
let root = builder.root(ComputedStyle::block());
// ... add children ...
let tree = builder.build();

let result = compute_layout(&tree, &FixedWidthTextMeasure, Size::new(800.0, 600.0));
let root_rect = result.bounding_rect(tree.root());