menu

package
v0.1.116 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package menu contains Material 3 Menu components.

Reference: [Menus](https://m3.material.io/components/menus/overview) Specs: [Menus Specs](https://m3.material.io/components/menus/specs)

Index

Constants

View Source
const DropdownMenuItemDefaultMaxWidth unit.Dp = 280

DropdownMenuItemDefaultMaxWidth is the maximum width for menu items.

View Source
const DropdownMenuItemDefaultMinWidth unit.Dp = 112

DropdownMenuItemDefaultMinWidth is the minimum width for menu items.

View Source
const DropdownMenuItemHorizontalPadding unit.Dp = 12

DropdownMenuItemHorizontalPadding is the horizontal padding for menu items.

View Source
const DropdownMenuVerticalPadding unit.Dp = 8

DropdownMenuVerticalPadding is the vertical padding inside the menu container.

View Source
const MenuHorizontalMargin unit.Dp = 48

MenuHorizontalMargin is the horizontal margin around the menu.

View Source
const MenuListItemContainerHeight unit.Dp = 48

MenuListItemContainerHeight is the default height for menu items.

View Source
const MenuVerticalMargin unit.Dp = 48

MenuVerticalMargin is the vertical margin around the menu.

View Source
const ShadowElevation unit.Dp = 3 // MenuTokens.ContainerElevation

ShadowElevation is the default shadow elevation for a menu.

View Source
const TonalElevation unit.Dp = 0 // ElevationTokens.Level0

TonalElevation is the default tonal elevation for a menu.

Variables

View Source
var MenuDefaults = menuDefaults{}

MenuDefaults contains default values used for DropdownMenu and DropdownMenuItem. Reference: https://m3.material.io/components/menus/specs

Functions

func DropdownMenu(
	expanded bool,
	onDismissRequest func(),
	menuItems []api.Composable,
	options ...DropdownMenuOption,
) api.Composable

DropdownMenu Composable Uses a Popup to display content on top of other content.

func DropdownMenuItem(
	textStr string,
	onClick func(),
	options ...DropdownMenuItemOption,
) api.Composable

DropdownMenuItem Composable

func MenuItems(items ...api.Composable) []api.Composable

Types

type Composer

type Composer = api.Composer

type ContentPadding added in v0.1.51

type ContentPadding struct {
	Start  unit.Dp
	Top    unit.Dp
	End    unit.Dp
	Bottom unit.Dp
}

ContentPadding represents padding values for content.

type DropdownMenuColors struct {
	ContainerColor graphics.Color
}

func DefaultDropdownMenuColors

func DefaultDropdownMenuColors(c Composer) DropdownMenuColors
type DropdownMenuItemColors struct {
	TextColor                 graphics.Color
	LeadingIconColor          graphics.Color
	TrailingIconColor         graphics.Color
	DisabledTextColor         graphics.Color
	DisabledLeadingIconColor  graphics.Color
	DisabledTrailingIconColor graphics.Color
}

func DefaultDropdownMenuItemColors

func DefaultDropdownMenuItemColors(c Composer) DropdownMenuItemColors
func (c DropdownMenuItemColors) LeadingIconColorFor(enabled bool) graphics.Color

LeadingIconColorFor returns the leading icon color based on enabled state.

func (c DropdownMenuItemColors) TextColorFor(enabled bool) graphics.Color

TextColorFor returns the text color based on enabled state.

func (c DropdownMenuItemColors) TrailingIconColorFor(enabled bool) graphics.Color

TrailingIconColorFor returns the trailing icon color based on enabled state.

type DropdownMenuItemOption func(*DropdownMenuItemOptions)

func WithEnabled

func WithEnabled(enabled bool) DropdownMenuItemOption

func WithLeadingIcon

func WithLeadingIcon(icon api.Composable) DropdownMenuItemOption

func WithMenuItemModifier

func WithMenuItemModifier(mod ui.Modifier) DropdownMenuItemOption

func WithTrailingIcon

func WithTrailingIcon(icon api.Composable) DropdownMenuItemOption
type DropdownMenuItemOptions struct {
	Modifier     ui.Modifier
	LeadingIcon  api.Composable
	TrailingIcon api.Composable
	Enabled      bool
}

func DefaultDropdownMenuItemOptions

func DefaultDropdownMenuItemOptions() DropdownMenuItemOptions
type DropdownMenuOption func(*DropdownMenuOptions)

func WithModifier

func WithModifier(m ui.Modifier) DropdownMenuOption

func WithOffset

func WithOffset(x, y unit.Dp) DropdownMenuOption
type DropdownMenuOptions struct {
	Modifier ui.Modifier
	OffsetX  unit.Dp
	OffsetY  unit.Dp
}

func DefaultDropdownMenuOptions

func DefaultDropdownMenuOptions() DropdownMenuOptions

Jump to

Keyboard shortcuts

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