Incular logoIncular
API ReferenceLayout Widgets

Visibility & Offstage

Conditional display with state, size, animation, and semantics retention.

Visibility conditionally displays its child; preservation flags imply retention of the hidden subtree. Offstage hides without unmounting: measured, but no paint, hit-test, or semantics.

use incular::prelude::*;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let shown = Signal::new(true);
    let visible = shown.clone();
    let app = Application::new(move |_cx| {
        Container::builder()
            .padding(EdgeInsets::all(24.0))
            .alignment(Alignment::CENTER)
            .child(
                Visibility::new(Text::new("Now you see me"))
                    .visible(visible.get())
                    .maintain_state(true)
                    .replacement(Text::new("Hidden")),
            )
            .build()
            .into()
    })?;
    incular::run(app)?;
    Ok(())
}

Props

Prop

Type

Related: Opacity, TickerMode.

On this page