Constant freya_elements::elements::rect::reference

source ·
pub const reference: (&'static str, Option<&'static str>, bool);
Expand description

Attach a reference to an element to track its layout and metadata.

This attribute is used in conjunction with hooks like use_node, use_node_signal, or other node reference hooks to observe and respond to changes in an element’s layout.

§Example

fn app() -> Element {
    // Basic usage with use_node
    let (reference, layout) = use_node();

    // Alternative usage with use_node_signal for reactive access
    // let (reference, layout_signal) = use_node_signal();

    rsx!(
        rect {
            width: "100%",
            height: "100%",
            reference,
            label {
                "Width: {layout.area.width()}, Height: {layout.area.height()}"
            }
        }
    )
}