Skip to main content

navigation_rail_item

Function navigation_rail_item 

Source
pub fn navigation_rail_item(
    rail: NavigationRailScope,
) -> NavigationRailItemBuilder
Expand description

Renders a single destination inside navigation_rail.

§Usage

Declare one primary destination in a navigation rail content slot.

§Parameters

  • rail — layout configuration supplied by the parent content slot.
  • label — text label shown next to or below the icon.
  • icon — optional icon rendered for the item.
  • badge — optional update marker, overlapping a collapsed icon or following an expanded label.
  • accessibility_description — additional announcement such as a notification count.
  • selected — whether this item is the active destination.
  • on_click — callback invoked after the item becomes selected.

§Examples

use tessera_components::navigation_rail::{navigation_rail, navigation_rail_item};
use tessera_ui::{remember, tessera};

#[tessera]
fn demo() {
    let selected = remember(|| 0usize);
    navigation_rail().content(move |rail| {
        navigation_rail_item(rail)
            .label("Home")
            .selected(selected.get() == 0)
            .on_click(move || selected.set(0));
    });
}