Skip to main content

NavigationItem

Function NavigationItem 

Source
pub fn NavigationItem(_: NavigationItemProps) -> Element
Expand description

One destination inside a Navigation.

The label and the icon are properties rather than a child tree, because the three presentations disagree about how they go together: a bottom bar stacks a small label under the icon, a rail may drop the label entirely, a drawer sets the label beside the icon and left-aligns the row. A Column { Icon, Text } handed over as children would have settled that question in the Host, where the window’s width is not known.

The icon is a meaning, never a picture: IconRole::Inbox comes out as this design system’s inbox.

§Props

For details, see the props struct definition.

  • weight : Option<f32>
  • width : Option<f32>
  • height : Option<f32>
  • padding : Option<f32>
  • padding_role : Option<SpaceRole>
  • background : Option<Paint>
  • shape_role : Option<ShapeRole>
  • corner_radius : Option<f32>
  • border_width : Option<f32>
  • border_color : Option<Paint>
  • elevation : Option<f32>
  • fill_max_width : bool
  • fill_max_height : bool
  • text : String
  • icon : Option<IconRole>
  • color : Option<Paint>

    The colour of this destination’s icon and label, in both states.

    The design system decides what selected looks like where this is not set, which is what an adaptive application wants. A unified one names it, because its reference may have no accent in the bar at all and a system asked the question answers with its own.

  • enabled : bool
  • section : Option<String>

    The named group of the strip this destination belongs to.

    Neighbouring destinations carrying the same name are one group and the name is its heading. A destination that names none belongs to no group and is drawn where it always was. What a heading looks like is the design system’s.

  • on_click : EventHandler<()>