API ReferenceLayout Widgets
Widget
The immutable descriptor all widgets convert into, with keys and semantics.
Widget is a cheap immutable (Rc) descriptor; live identity lives in
Element. Every built-in widget implements From<X> for Widget, so builders
take impl Into<Widget> children — the canonical pattern is .into() per
child.
| Member | Purpose |
|---|---|
with_key(key) | Reconciliation identity (ValueKey / LocalKey / UniqueKey) |
accessibility_label / accessibility_description | Screen-reader naming |
exclude_semantics | Hide subtree from the tree |
merge_semantics | Merge subtree into one node |
block_semantics | Block subtree semantics |
use incular::prelude::*;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let app = Application::new(|_cx| {
Container::builder()
.padding(EdgeInsets::all(24.0))
.alignment(Alignment::CENTER)
.child(
Column::builder()
.main_axis_size(MainAxisSize::Min)
.spacing(8.0)
.children(Vec::<Widget>::from([
Text::new("Title").into(),
Container::builder()
.child(Text::new("Body"))
.build().into(),
]))
.build(),
)
.build()
.into()
})?;
incular::run(app)?;
Ok(())
}Keys and identity
Key / ValueKey / LocalKey / UniqueKey control reconciliation: matching
keys reuse state across rebuilds. Attach them in a runnable program:
use incular::prelude::*;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let app = Application::new(|_cx| {
let keyed: Widget = Text::new("Keyed").into();
Container::builder()
.padding(EdgeInsets::all(24.0))
.alignment(Alignment::CENTER)
.child(keyed.with_key("item-1"))
.build()
.into()
})?;
incular::run(app)?;
Ok(())
}Semantics modifiers
Semantics modifiers
use incular::prelude::*;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let app = Application::new(|_cx| {
let labeled: Widget = Text::new("Close").into();
Container::builder()
.padding(EdgeInsets::all(24.0))
.alignment(Alignment::CENTER)
.child(
labeled
.accessibility_label("Close dialog")
.exclude_semantics(),
)
.build()
.into()
})?;
incular::run(app)?;
Ok(())
}merge_semantics() and block_semantics() scope subtree semantics the same
way; debug_type_name("MyWidget") labels nodes in diagnostics.