menu

package
v0.0.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 15, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package menu provides menu and navigation components following shadcn/ui patterns. Menu components support icons, badges, and active states.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Item

func Item(href string, label g.Node, opts ...ItemOption) g.Node

Item creates a menu item (link or button)

Example:

menu.Item("/dashboard", g.Text("Dashboard"), menu.Active(), menu.WithIcon(icon))
func Menu(children ...g.Node) g.Node

Menu creates a vertical navigation menu

Example:

menu.Menu(
    menu.Item("/", g.Text("Home"), menu.Active()),
    menu.Item("/about", g.Text("About")),
)
func MenuWithOptions(opts []MenuOption, children ...g.Node) g.Node

MenuWithOptions creates menu with custom options

func Section

func Section(label string, children ...g.Node) g.Node

Section creates a grouped menu section with label

Example:

menu.Section("Main",
    menu.Item("/", g.Text("Home")),
    menu.Item("/about", g.Text("About")),
)

func SectionWithOptions

func SectionWithOptions(label string, opts []SectionOption, children ...g.Node) g.Node

SectionWithOptions creates section with custom options

func Separator

func Separator() g.Node

Separator creates a menu separator/divider

Example:

menu.Separator()

Types

type ItemOption

type ItemOption func(*ItemProps)

ItemOption is a functional option for configuring menu items

func Active

func Active() ItemOption

Active marks the item as active

func WithBadge

func WithBadge(badge g.Node) ItemOption

WithBadge adds a badge to the item

func WithHref

func WithHref(href string) ItemOption

WithHref sets the link href

func WithIcon

func WithIcon(icon g.Node) ItemOption

WithIcon adds an icon to the item

func WithItemAttrs

func WithItemAttrs(attrs ...g.Node) ItemOption

WithItemAttrs adds custom attributes to item

func WithItemClass

func WithItemClass(class string) ItemOption

WithItemClass adds custom classes to item

func WithVariant

func WithVariant(variant string) ItemOption

WithVariant sets the menu item variant

type ItemProps

type ItemProps struct {
	Href    string
	Active  bool
	Icon    g.Node
	Badge   g.Node
	Variant string // "default", "ghost"
	Class   string
	Attrs   []g.Node
}

ItemProps defines menu item configuration

type MenuOption func(*MenuProps)

MenuOption is a functional option for configuring menus

func WithAttrs

func WithAttrs(attrs ...g.Node) MenuOption

WithAttrs adds custom attributes to menu

func WithClass

func WithClass(class string) MenuOption

WithClass adds custom classes to menu

type MenuProps struct {
	Class string
	Attrs []g.Node
}

MenuProps defines menu configuration

type SectionOption

type SectionOption func(*SectionProps)

SectionOption is a functional option for configuring menu sections

func WithSectionAttrs

func WithSectionAttrs(attrs ...g.Node) SectionOption

WithSectionAttrs adds custom attributes to section

func WithSectionClass

func WithSectionClass(class string) SectionOption

WithSectionClass adds custom classes to section

type SectionProps

type SectionProps struct {
	Label string
	Class string
	Attrs []g.Node
}

SectionProps defines menu section configuration

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL