API ReferenceLayout Widgets
IndexedStack
Stack showing one child at a time while keeping all laid out.
IndexedStack lays out every child but paints only the selected index —
state-preserving tab bodies. Defaults: index = 0,
alignment = TOP_LEFT, fit = Loose, clip_behavior = HardEdge.
Props
Prop
Type
Construction
Signal-driven tabs — copy, paste, and run:
use incular::prelude::*;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let tab = Signal::new(0usize);
let current = tab.clone();
let app = Application::new(move |_cx| {
Container::builder()
.padding(EdgeInsets::all(24.0))
.alignment(Alignment::CENTER)
.child(
IndexedStack::new(Vec::<Widget>::from([
Text::new("Home page").into(),
Text::new("Search page").into(),
Text::new("Settings page").into(),
]))
.index(current.get())
.alignment(Alignment::CENTER),
)
.build()
.into()
})?;
incular::run(app)?;
Ok(())
}IndexedStack::new(pages).index(1).alignment(Alignment::CENTER).fit(StackFit::Expand)
shows the same calls without a signal.
Methods
pub fn new(children: impl IntoIterator<Item = impl Into<Widget>>) -> Self
pub fn index(mut self, index: usize) -> Self
pub fn alignment(mut self, alignment: Alignment) -> Self
pub fn fit(mut self, fit: StackFit) -> Self
pub fn clip_behavior(mut self, clip: Clip) -> Self
pub fn get_index(&self) -> usizeDrive index from a Signal for tab navigation
without losing per-tab state.
Related: Stack.