Bus UI Navigation

Menu renders bounded command choices.

Use Menu when a view needs an immediate command menu with a validated trigger, item list, selected value, and callback-backed choices.

Public API

Functionui.Menu
Propsui.MenuProps
Item propsui.MenuItem
Use forImmediate menus with deterministic item values and callback dispatch.

Example

Loading Menu demo...

Go API

import (
  gx "github.com/busdk/bus-gx/pkg/gx"
  ui "github.com/busdk/bus-ui/pkg/ui"
)

node, err := ui.Menu(ui.MenuProps{
  TriggerLabel: "Actions",
  Items: []ui.MenuItem{
    {Label: "Refresh", Value: "refresh", OnClick: handleMenu},
    {Label: "Archive", Value: "archive", OnClick: handleMenu},
  },
})

html, err := gx.RenderHTML(node)

In .gx source, keep the menu item list in a wrapper and call that wrapper from markup.

In .gx source, a menu is plain nested navigation markup with the current item marked in the tree.

.gx source

package navigationui

import gx "github.com/busdk/bus-gx/pkg/gx"

type PrimaryMenuProps struct {
  Current string
}

func PrimaryMenu(props PrimaryMenuProps) gx.Node {
  return <nav class="menu" aria-label="Primary">
  <a aria-current="page" href="/imports/index.html"><Text value={props.Current}></Text></a>
  <a href="/settings/index.html"><Text value={"Settings"}></Text></a>
</nav>
}

var menu = <PrimaryMenu current={"Imports"}></PrimaryMenu>