contextmenu

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2026 License: MIT Imports: 2 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ContextMenuCheckboxItemFixtures = gx.Fixtures[ContextMenuCheckboxItemProps]{
	"Checked":   {Name: "status-bar", Checked: true, Children: gx.Text("Status bar")},
	"Unchecked": {Name: "panel", Children: gx.Text("Panel")},
	"Disabled":  {Name: "activity", Disabled: true, Children: gx.Text("Activity bar")},
}
View Source
var ContextMenuFixtures = gx.Fixtures[ContextMenuProps]{
	"Menu": {Id: "demo-context", Class: "w-52", Children: gx.Frag(
		ContextMenuItem(ContextMenuItemProps{Children: gx.Frag(
			gx.Text("Copy"),
			ContextMenuShortcut(ContextMenuShortcutProps{Children: gx.Text("⌘C")}),
		)}),
		ContextMenuItem(ContextMenuItemProps{Children: gx.Text("Cut")}),
		ContextMenuSeparator(ContextMenuSeparatorProps{}),
		ContextMenuCheckboxItem(ContextMenuCheckboxItemProps{Name: "bookmarks", Checked: true, Children: gx.Text("Show bookmarks")}),
		ContextMenuSeparator(ContextMenuSeparatorProps{}),
		ContextMenuRadioGroup(ContextMenuRadioGroupProps{Label: "People", Children: gx.Frag(
			ContextMenuLabel(ContextMenuLabelProps{Inset: true, Children: gx.Text("People")}),
			ContextMenuRadioItem(ContextMenuRadioItemProps{Name: "demo-context-person", Value: "ada", Checked: true, Children: gx.Text("Ada")}),
			ContextMenuRadioItem(ContextMenuRadioItemProps{Name: "demo-context-person", Value: "grace", Children: gx.Text("Grace")}),
		)}),
		ContextMenuSeparator(ContextMenuSeparatorProps{}),
		ContextMenuLink(ContextMenuLinkProps{Href: gx.URL("/docs"), Children: gx.Text("Docs")}),
		ContextMenuItem(ContextMenuItemProps{Variant: Destructive, Children: gx.Text("Delete")}),
	)},
	"Sub": {Id: "demo-context-sub", Class: "w-52", Children: gx.Frag(
		ContextMenuItem(ContextMenuItemProps{Children: gx.Text("Back")}),
		ContextMenuSub(ContextMenuSubProps{Children: gx.Frag(
			ContextMenuSubTrigger(ContextMenuSubTriggerProps{Children: gx.Text("More tools")}),
			ContextMenuSubContent(ContextMenuSubContentProps{Class: "w-48", Children: gx.Frag(
				ContextMenuItem(ContextMenuItemProps{Children: gx.Text("Save page")}),
				ContextMenuItem(ContextMenuItemProps{Children: gx.Text("Create shortcut")}),
				ContextMenuSeparator(ContextMenuSeparatorProps{}),
				ContextMenuItem(ContextMenuItemProps{Children: gx.Text("Developer tools")}),
			)}),
		)}),
		ContextMenuSeparator(ContextMenuSeparatorProps{}),
		ContextMenuItem(ContextMenuItemProps{Children: gx.Text("Reload")}),
	)},
}
View Source
var ContextMenuGroupFixtures = gx.Fixtures[ContextMenuGroupProps]{
	"Default": {Label: "Account", Children: gx.Frag(
		ContextMenuItem(ContextMenuItemProps{Children: gx.Text("Profile")}),
		ContextMenuItem(ContextMenuItemProps{Children: gx.Text("Billing")}),
	)},
}
View Source
var ContextMenuItemFixtures = gx.Fixtures[ContextMenuItemProps]{
	"Item":        {Children: gx.Text("Profile")},
	"Inset":       {Inset: true, Children: gx.Text("Profile")},
	"Destructive": {Variant: Destructive, Children: gx.Text("Delete")},
	"Disabled":    {Disabled: true, Children: gx.Text("Profile")},
}
View Source
var ContextMenuLabelFixtures = gx.Fixtures[ContextMenuLabelProps]{
	"Label": {Children: gx.Text("My account")},
	"Inset": {Inset: true, Children: gx.Text("My account")},
}
View Source
var ContextMenuLinkFixtures = gx.Fixtures[ContextMenuLinkProps]{"Link": {Href: gx.URL("/docs"), Children: gx.Text("Documentation")}}
View Source
var ContextMenuRadioGroupFixtures = gx.Fixtures[ContextMenuRadioGroupProps]{
	"Default": {Label: "Position", Children: gx.Frag(
		ContextMenuRadioItem(ContextMenuRadioItemProps{Name: "context-menu-group-position", Value: "top", Checked: true, Children: gx.Text("Top")}),
		ContextMenuRadioItem(ContextMenuRadioItemProps{Name: "context-menu-group-position", Value: "bottom", Children: gx.Text("Bottom")}),
	)},
}
View Source
var ContextMenuRadioItemFixtures = gx.Fixtures[ContextMenuRadioItemProps]{
	"Checked":   {Name: "context-menu-item-checked", Value: "top", Checked: true, Children: gx.Text("Top")},
	"Unchecked": {Name: "context-menu-item-unchecked", Value: "bottom", Children: gx.Text("Bottom")},
}
View Source
var ContextMenuSeparatorFixtures = gx.Fixtures[ContextMenuSeparatorProps]{"Default": {}}
View Source
var ContextMenuShortcutFixtures = gx.Fixtures[ContextMenuShortcutProps]{"Default": {Children: gx.Text("⌘K")}}
View Source
var ContextMenuSubContentFixtures = gx.Fixtures[ContextMenuSubContentProps]{
	"Content": {Class: "w-48", Children: gx.Frag(
		ContextMenuItem(ContextMenuItemProps{Children: gx.Text("Save page")}),
		ContextMenuItem(ContextMenuItemProps{Children: gx.Text("Create shortcut")}),
		ContextMenuSeparator(ContextMenuSeparatorProps{}),
		ContextMenuItem(ContextMenuItemProps{Children: gx.Text("Developer tools")}),
	)},
}
View Source
var ContextMenuSubFixtures = gx.Fixtures[ContextMenuSubProps]{
	"Default": {Children: gx.Frag(
		ContextMenuSubTrigger(ContextMenuSubTriggerProps{Children: gx.Text("More tools")}),
		ContextMenuSubContent(ContextMenuSubContentProps{Children: gx.Frag(
			ContextMenuItem(ContextMenuItemProps{Children: gx.Text("Save page")}),
			ContextMenuItem(ContextMenuItemProps{Children: gx.Text("Create shortcut")}),
		)}),
	)},
}
View Source
var ContextMenuSubTriggerFixtures = gx.Fixtures[ContextMenuSubTriggerProps]{
	"Trigger":  {Children: gx.Text("More tools")},
	"Inset":    {Inset: true, Children: gx.Text("More tools")},
	"Disabled": {Disabled: true, Children: gx.Text("More tools")},
}
View Source
var ContextMenuTriggerFixtures = gx.Fixtures[ContextMenuTriggerProps]{
	"Default": {
		Id:       "demo-context",
		Class:    "flex h-[150px] w-[300px] items-center justify-center rounded-md border border-dashed border-border text-sm",
		Children: gx.Text("Right-click here"),
	},
	"Sub": {
		Id:       "demo-context-sub",
		Class:    "flex h-[150px] w-[300px] items-center justify-center rounded-md border border-dashed border-border text-sm",
		Children: gx.Text("Right-click for a sub-menu"),
	},
}

Functions

func ContextMenu

func ContextMenu(p ContextMenuProps) gx.Node

func ContextMenuCheckboxItem

func ContextMenuCheckboxItem(p ContextMenuCheckboxItemProps) gx.Node

func ContextMenuCheckboxItemWrap

func ContextMenuCheckboxItemWrap(n gx.Node) gx.Node

ContextMenuCheckboxItemWrap renders the item inside a menu, as a page uses it.

func ContextMenuGroup

func ContextMenuGroup(p ContextMenuGroupProps) gx.Node

func ContextMenuGroupWrap

func ContextMenuGroupWrap(n gx.Node) gx.Node

ContextMenuGroupWrap renders the group inside a menu, as a page uses it.

func ContextMenuItem

func ContextMenuItem(p ContextMenuItemProps) gx.Node

func ContextMenuItemWrap

func ContextMenuItemWrap(n gx.Node) gx.Node

ContextMenuItemWrap renders the item inside a menu, as a page uses it.

func ContextMenuLabel

func ContextMenuLabel(p ContextMenuLabelProps) gx.Node
func ContextMenuLink(p ContextMenuLinkProps) gx.Node

func ContextMenuLinkWrap

func ContextMenuLinkWrap(n gx.Node) gx.Node

ContextMenuLinkWrap renders the item inside a menu, as a page uses it.

func ContextMenuRadioGroup

func ContextMenuRadioGroup(p ContextMenuRadioGroupProps) gx.Node

func ContextMenuRadioGroupWrap

func ContextMenuRadioGroupWrap(n gx.Node) gx.Node

ContextMenuRadioGroupWrap renders the group inside a menu, as a page uses it.

func ContextMenuRadioItem

func ContextMenuRadioItem(p ContextMenuRadioItemProps) gx.Node

func ContextMenuRadioItemWrap

func ContextMenuRadioItemWrap(n gx.Node) gx.Node

ContextMenuRadioItemWrap renders the item inside a menu, as a page uses it.

func ContextMenuSeparator

func ContextMenuSeparator(p ContextMenuSeparatorProps) gx.Node

func ContextMenuShortcut

func ContextMenuShortcut(p ContextMenuShortcutProps) gx.Node

func ContextMenuSub

func ContextMenuSub(p ContextMenuSubProps) gx.Node

func ContextMenuSubContent

func ContextMenuSubContent(p ContextMenuSubContentProps) gx.Node

func ContextMenuSubContentWrap

func ContextMenuSubContentWrap(n gx.Node) gx.Node

ContextMenuSubContentWrap renders the content behind its trigger inside a menu, as a page uses it.

func ContextMenuSubTrigger

func ContextMenuSubTrigger(p ContextMenuSubTriggerProps) gx.Node

func ContextMenuSubTriggerWrap

func ContextMenuSubTriggerWrap(n gx.Node) gx.Node

ContextMenuSubTriggerWrap renders the trigger inside a menu, as a page uses it.

func ContextMenuSubWrap

func ContextMenuSubWrap(n gx.Node) gx.Node

ContextMenuSubWrap renders the sub-menu inside a menu, as a page uses it.

func ContextMenuTrigger

func ContextMenuTrigger(p ContextMenuTriggerProps) gx.Node

Types

type ContextMenuCheckboxItemProps

type ContextMenuCheckboxItemProps struct {
	// Name is the name attribute of the checkbox input. A form or a signal reads it.
	Name string
	// Value is the value that the form sends when the item is checked.
	Value string
	// Checked sets the item as checked on the first render.
	Checked bool
	// Disabled turns the item off. The arrow keys pass it.
	Disabled bool
	// Class adds classes to the root element.
	Class string
	// Children is the label of the item.
	Children gx.Node
	// Attrs adds HTML attributes to the root element.
	Attrs gx.Attrs
}

type ContextMenuGroupProps

type ContextMenuGroupProps struct {
	// Label is the accessible name of the group. It is not visible.
	Label string
	// Class adds classes to the root element.
	Class string
	// Children is the items of the group.
	Children gx.Node
	// Attrs adds HTML attributes to the root element.
	Attrs gx.Attrs
}

type ContextMenuItemProps

type ContextMenuItemProps struct {
	// Variant sets the visual style: Default or Destructive.
	Variant Variant
	// Inset adds left padding, so the item lines up with the checkbox and radio items.
	Inset bool
	// Disabled turns the item off. The arrow keys pass it.
	Disabled bool
	// Class adds classes to the root element.
	Class string
	// Children is the content of the item.
	Children gx.Node
	// Attrs adds HTML attributes to the root element.
	Attrs gx.Attrs
}

type ContextMenuLabelProps

type ContextMenuLabelProps struct {
	// Inset adds left padding, so the label lines up with the checkbox and radio items.
	Inset bool
	// Class adds classes to the root element.
	Class string
	// Children is the text of the label.
	Children gx.Node
	// Attrs adds HTML attributes to the root element.
	Attrs gx.Attrs
}

type ContextMenuLinkProps

type ContextMenuLinkProps struct {
	// Href is the URL that the link opens.
	Href gx.URL
	// Class adds classes to the root element.
	Class string
	// Children is the content of the link.
	Children gx.Node
	// Attrs adds HTML attributes to the root element.
	Attrs gx.Attrs
}

type ContextMenuProps

type ContextMenuProps struct {
	// Id is the id of the root element. The trigger opens the menu by this id.
	Id string
	// Class adds classes to the root element.
	Class string
	// Children is the menu items.
	Children gx.Node
	// Attrs adds HTML attributes to the root element.
	Attrs gx.Attrs
}

type ContextMenuRadioGroupProps

type ContextMenuRadioGroupProps struct {
	// Label is the accessible name of the group. It is not visible.
	Label string
	// Class adds classes to the root element.
	Class string
	// Children is the radio items of the group.
	Children gx.Node
	// Attrs adds HTML attributes to the root element.
	Attrs gx.Attrs
}

type ContextMenuRadioItemProps

type ContextMenuRadioItemProps struct {
	// Name is the name attribute of the radio input. The radio items of one group share
	// the same name.
	Name string
	// Value is the value that the form sends when the item is checked.
	Value string
	// Checked sets the item as checked on the first render.
	Checked bool
	// Disabled turns the item off. The arrow keys pass it.
	Disabled bool
	// Class adds classes to the root element.
	Class string
	// Children is the label of the item.
	Children gx.Node
	// Attrs adds HTML attributes to the root element.
	Attrs gx.Attrs
}

type ContextMenuSeparatorProps

type ContextMenuSeparatorProps struct {
	// Class adds classes to the root element.
	Class string
	// Attrs adds HTML attributes to the root element.
	Attrs gx.Attrs
}

type ContextMenuShortcutProps

type ContextMenuShortcutProps struct {
	// Class adds classes to the root element.
	Class string
	// Children is the text of the keyboard shortcut.
	Children gx.Node
	// Attrs adds HTML attributes to the root element.
	Attrs gx.Attrs
}

type ContextMenuSubContentProps

type ContextMenuSubContentProps struct {
	// Class adds classes to the root element.
	Class string
	// Children is the list of items of the sub-menu.
	Children gx.Node
	// Attrs adds HTML attributes to the root element.
	Attrs gx.Attrs
}

type ContextMenuSubProps

type ContextMenuSubProps struct {
	// Class adds classes to the root element.
	Class string
	// Children is the sub-menu trigger, followed by the sub-menu content.
	Children gx.Node
	// Attrs adds HTML attributes to the root element.
	Attrs gx.Attrs
}

type ContextMenuSubTriggerProps

type ContextMenuSubTriggerProps struct {
	// Inset adds left padding, so the trigger lines up with the checkbox and radio items.
	Inset bool
	// Disabled turns the trigger off. The arrow keys pass it.
	Disabled bool
	// Class adds classes to the root element.
	Class string
	// Children is the label of the trigger. A chevron follows it.
	Children gx.Node
	// Attrs adds HTML attributes to the root element.
	Attrs gx.Attrs
}

type ContextMenuTriggerProps

type ContextMenuTriggerProps struct {
	// Id is the id of the menu that a right click on the trigger opens.
	Id string
	// Class adds classes to the root element. The trigger has no style of its own.
	Class string
	// Children is the content of the area that takes the right click.
	Children gx.Node
	// Attrs adds HTML attributes to the root element.
	Attrs gx.Attrs
}

type Variant

type Variant string

Variant is the visual style of a menu item.

const (
	Default     Variant = "default"
	Destructive Variant = "destructive"
)

The variants of contextmenu.ContextMenuItem.

Jump to

Keyboard shortcuts

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