Documentation
¶
Overview ¶
Package dropdown provides dropdown menu components with keyboard navigation.
Dropdowns display a list of options or actions when clicked. They support positioning, alignment, keyboard navigation, and click-outside-to-close.
Basic usage:
dropdown.Dropdown(
dropdown.DropdownProps{
Position: forgeui.PositionBottom,
Align: forgeui.AlignStart,
},
button.Button(g.Text("Options")),
html.Div(g.Text("Dropdown content")),
)
Index ¶
- func ContextMenu(trigger g.Node, content ...g.Node) g.Node
- func ContextMenuCheckboxItem(id, label string, checked bool) g.Node
- func ContextMenuContent(children ...g.Node) g.Node
- func ContextMenuItem(children ...g.Node) g.Node
- func ContextMenuItemWithIcon(icon, label g.Node) g.Node
- func ContextMenuLabel(text string) g.Node
- func ContextMenuRadioGroup(value string, children ...g.Node) g.Node
- func ContextMenuRadioItem(value, label string) g.Node
- func ContextMenuSeparator() g.Node
- func ContextMenuShortcut(text string) g.Node
- func ContextMenuSub(trigger g.Node, content ...g.Node) g.Node
- func Dropdown(props DropdownProps, trigger g.Node, content ...g.Node) g.Node
- func DropdownClose(child g.Node) g.Node
- func DropdownMenu(children ...g.Node) g.Node
- func DropdownMenuCheckboxItem(id, label string, checked bool) g.Node
- func DropdownMenuContent(children ...g.Node) g.Node
- func DropdownMenuContentWithAlign(align forgeui.Align, children ...g.Node) g.Node
- func DropdownMenuItem(children ...g.Node) g.Node
- func DropdownMenuItemWithIcon(icon, label g.Node) g.Node
- func DropdownMenuLabel(text string) g.Node
- func DropdownMenuRadioGroup(value string, children ...g.Node) g.Node
- func DropdownMenuRadioItem(value, label string) g.Node
- func DropdownMenuSeparator() g.Node
- func DropdownMenuShortcut(text string) g.Node
- func DropdownMenuSub(trigger g.Node, content ...g.Node) g.Node
- func DropdownMenuTrigger(child g.Node) g.Node
- type DropdownProps
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContextMenu ¶
ContextMenu creates a context menu triggered by right-click.
Context menus appear at the cursor position when right-clicking on the trigger element. They share the same item components as DropdownMenu (items, separators, checkboxes, etc.).
Example:
contextMenu.ContextMenu(
html.Div(
html.Class("p-4 border border-border"),
g.Text("Right-click me"),
),
contextMenu.ContextMenuContent(
contextMenu.ContextMenuItem(g.Text("Copy")),
contextMenu.ContextMenuItem(g.Text("Paste")),
contextMenu.ContextMenuSeparator(),
contextMenu.ContextMenuItem(g.Text("Delete")),
),
)
func ContextMenuCheckboxItem ¶
ContextMenuCheckboxItem creates a checkable context menu item.
func ContextMenuContent ¶
ContextMenuContent creates the context menu content panel.
func ContextMenuItem ¶
ContextMenuItem creates a context menu item. Same as DropdownMenuItem but closes the context menu on click.
func ContextMenuItemWithIcon ¶
ContextMenuItemWithIcon creates a context menu item with an icon.
func ContextMenuLabel ¶
ContextMenuLabel creates a label for grouping items.
func ContextMenuRadioGroup ¶
ContextMenuRadioGroup creates a radio group container.
func ContextMenuRadioItem ¶
ContextMenuRadioItem creates a radio context menu item.
func ContextMenuSeparator ¶
ContextMenuSeparator creates a visual separator.
func ContextMenuShortcut ¶
ContextMenuShortcut displays a keyboard shortcut hint.
func ContextMenuSub ¶
ContextMenuSub creates a submenu.
func Dropdown ¶
Dropdown creates a basic dropdown with positioning.
The dropdown toggles open/closed on click and closes when clicking outside. It supports positioning and alignment relative to the trigger.
Example:
dropdown.Dropdown(
dropdown.DropdownProps{
Position: forgeui.PositionBottom,
Align: forgeui.AlignEnd,
},
button.Button(g.Text("Menu")),
html.Div(
html.A(html.Href("#"), g.Text("Option 1")),
html.A(html.Href("#"), g.Text("Option 2")),
),
)
func DropdownClose ¶
DropdownClose wraps an element to close the dropdown when clicked.
func DropdownMenu ¶
DropdownMenu creates a dropdown menu container with compound API.
DropdownMenu provides a full-featured menu system with:
- Menu items with icons
- Keyboard navigation (arrows, enter, escape)
- Separators and labels
- Checkable items
- Radio items
- Submenu support
- Keyboard shortcuts display
Example:
dropdown.DropdownMenu(
dropdown.DropdownMenuTrigger(button.Button(g.Text("Options"))),
dropdown.DropdownMenuContent(
dropdown.DropdownMenuItem(g.Text("Profile")),
dropdown.DropdownMenuItem(g.Text("Settings")),
dropdown.DropdownMenuSeparator(),
dropdown.DropdownMenuItem(g.Text("Logout")),
),
)
func DropdownMenuCheckboxItem ¶
DropdownMenuCheckboxItem creates a checkable menu item.
func DropdownMenuContent ¶
DropdownMenuContent creates the menu content panel.
func DropdownMenuContentWithAlign ¶
DropdownMenuContentWithAlign creates menu content with custom alignment
func DropdownMenuItem ¶
DropdownMenuItem creates a menu item.
func DropdownMenuItemWithIcon ¶
DropdownMenuItemWithIcon creates a menu item with an icon.
func DropdownMenuLabel ¶
DropdownMenuLabel creates a label for grouping items.
func DropdownMenuRadioGroup ¶
DropdownMenuRadioGroup creates a radio group container.
func DropdownMenuRadioItem ¶
DropdownMenuRadioItem creates a radio menu item.
func DropdownMenuSeparator ¶
DropdownMenuSeparator creates a visual separator.
func DropdownMenuShortcut ¶
DropdownMenuShortcut displays a keyboard shortcut hint.
func DropdownMenuSub ¶
DropdownMenuSub creates a submenu.
Types ¶
type DropdownProps ¶
type DropdownProps struct {
// Position specifies where the dropdown appears relative to trigger
Position forgeui.Position
// Align specifies how the dropdown aligns with the trigger
Align forgeui.Align
// Class adds additional CSS classes
Class string
}
DropdownProps defines configuration for a dropdown