Props, events and models
Pass values down, send typed events up and bind controlled values.
On this page
Props pass values to a child
A child declares a public Props struct. The parent supplies its fields. rustc checks the field names and types.
<view>
<Row gap={12.0}>
<Text text={format!("{}: {}", props.label, props.count)} />
<Button text="Increment" @click={props.on_increment.clone()} />
</Row>
</view>
<rust>
use inrux::prelude::*;
pub struct Props {
pub label: &'static str,
pub count: u32,
pub on_increment: Emit<()>,
}
</rust>
Import the component in the parent's Rust block and use its alias in the view:
use crate::components::counter as Counter;
<Counter label="Tasks" count={count} @increment={increment} />
These parent fragments belong in an existing stateful component. See the scaffold for the surrounding typed state declarations and handlers.
Events send information to the owner
@increment maps to on_increment: Emit<()>. A payload event such as @confirmed maps to on_confirmed: Emit<String> when the child sends a String. A payload-consuming parent handler takes (&mut State, String, &Context<State>).
Keep the controlled value in its owner. The child requests a change through an event instead of mutating the parent's fields. Handle event admission errors when using Emit directly in Rust.
Models pair a value with an update
<Input model:value={name} @input={mark_dirty} />
<Checkbox label="Receive updates" model:checked={receive_updates} />
model:value updates a String or Signal<String>. model:checked updates a bool or Signal<bool>. Use a retained field name such as name or a named nested path such as counter.name. Qualified state.field targets remain supported; props are readonly. The generated setter runs before an optional handler in the same coordinator command.
A custom component can expose a model by declaring value and on_update_value: Emit<T> in Props. The parent uses model:value={state.name}. A parent can add @update:value={mark_dirty} to observe the assignment.
Do not supply both a model and its controlled value/event pair. See the complete component contract for signatures and validation rules.
Readability rule
Pass values through props when the ownership relationship is local. Use typed provide/inject for services or shared reactive values needed by descendants. Do not replace clear props with a hidden global dependency.