# rsx

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-view-macros/proc_macro-rsx/

**proc macro** · [`ferroui-view-macros`](/docs/0.5.0/api/ferroui-view-macros/) · v0.5.0

```rust
bang macro rsx!
```

An element tree, expanded to the builders of `ferroui-view`.

```ignore
rsx! {
    StackPanel { spacing: 8.0,
        TextBlock { text: move || format!("Count: {}", count.get()) }
        Button { on_click: move |_| count.update(|c| *c += 1), "Increment" }
    }
}
```

- `Name { ... }` is an element of the control class or component `Name`
  in scope (`<Name as Builder>::builder()`): `StackPanel` is
  `stack_panel()`, `todo::Row` the component `Row` of the module `todo`.
- `name` alone gives the setter `name` the variable `name`, as a field of
  a struct is given (`TextBlock { text }`).
- `name: value` calls the setter `.name(value)`: a property
  (`spacing: 8.0`), a handler (`on_click: ...`), `key`, `name`, `class`.
- `Owner.name: value` sets an attached property: `Grid.row: 1` calls
  `.grid_row(1)`.
- `name(a, b)` calls a method of the builder with several arguments:
  `on_changed(TextBox::text_property(), handler)`,
  `set(Grid::row_property(), 1)` (the indexer `control[Property] = 1`
  upstream), `bind(TextBlock::text_property(), binding)`.
- `"text"` is a text child, `{expr}` any child (an element, a builder, a
  list, `for_each(..)`, `show(..)`), and a nested element a child.
- `if cond { .. } else { .. }` and `for x in items { .. }` choose and
  repeat children when the tree is built (for children that follow state,
  use `{for_each(..)}`, `{show(..)}` or `{dynamic(..)}`).

Several nodes at the root make a fragment.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.View.Macros/lib.rs#L49)

## Availability

Extracted for `aarch64-apple-darwin`. Cargo features are listed in the [crate index](/docs/0.5.0/api/).
