Function freya::components::Menu

source ·
pub fn Menu(_: MenuProps) -> Result<VNode, RenderError>
Expand description

Floating menu, use alongside [MenuItem].

§Example

fn app() -> Element {
   let mut show_menu = use_signal(|| false);

   rsx!(
       Body {
           Button {
               onpress: move |_| show_menu.toggle(),
               label { "Open Menu" }
           },
           if *show_menu.read() {
               Menu {
                   onclose: move |_| show_menu.set(false),
                   MenuButton {
                       label {
                           "Open"
                       }
                   }
                   MenuButton {
                       label {
                           "Save"
                       }
                   }
                   SubMenu {
                       menu: rsx!(
                           MenuButton {
                               label {
                                   "Some option"
                               }
                           }
                       ),
                       label {
                           "Options"
                       }
                   }
                   MenuButton {
                       label {
                           "Close"
                       }
                   }
               }
           }
       }
   )
}

§Props

For details, see the props struct definition.