Skip to main content

navigation_bar_item

Function navigation_bar_item 

Source
pub fn navigation_bar_item() -> NavigationBarItemBuilder
Expand description

Renders a single destination inside navigation_bar.

§Usage

Declare one primary destination in a navigation bar content slot.

§Parameters

  • label — text label shown under the icon.
  • icon — optional icon rendered above the label.
  • selected — whether this item is the active destination.
  • icon_position — place the icon above or before the label.
  • on_click — callback invoked after the item becomes selected.
  • accessibility_description — additional announcement such as an unread count.
  • label_behavior — whether the label is always shown or only when selected.

§Examples

use tessera_components::navigation_bar::{navigation_bar, navigation_bar_item};
use tessera_ui::{remember, tessera};

#[tessera]
fn demo() {
    let selected = remember(|| 0usize);
    navigation_bar().content(move |position| {
        navigation_bar_item().icon_position(position)
            .label("Home")
            .selected(selected.get() == 0)
            .on_click(move || selected.set(0));
    });
}