Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Style Builder Example

This example shows how a reusable base Style is composed with an additional layer through merged(...), including layout and spacing escape hatches.

  • File: examples/02_style_builder.rs
  • Run:
cargo run --example style_builder
  • Expected output: the merged padding, background, text color, width, constraints, layout tokens, radius, and shadow values.

Why this exists: it demonstrates that Twill’s core abstraction is style composition, not framework-specific components, and that arbitrary/custom values still live inside the same typed builder surface.