Documentation
¶
Overview ¶
Package command provides a command menu component with search and keyboard navigation.
The Command component is a fast, composable command menu for search and quick actions, inspired by shadcn/ui's command palette with ⌘K interaction pattern.
Basic usage:
command.Command(
command.CommandInput(),
command.CommandList(
command.CommandEmpty("No results found."),
command.CommandGroup("Suggestions",
command.CommandItem("Calendar"),
command.CommandItem("Search Emoji"),
),
),
)
Index ¶
- func Command(children ...g.Node) g.Node
- func CommandDialog(trigger g.Node, children ...g.Node) g.Node
- func CommandEmpty(message string) g.Node
- func CommandGroup(heading string, children ...g.Node) g.Node
- func CommandInput(opts ...CommandInputOption) g.Node
- func CommandItem(text string, opts ...CommandItemOption) g.Node
- func CommandList(children ...g.Node) g.Node
- func CommandSeparator() g.Node
- func CommandShortcut(keys ...string) g.Node
- type CommandInputOption
- type CommandInputProps
- type CommandItemOption
- func WithDisabled(disabled bool) CommandItemOption
- func WithItemAttrs(attrs ...g.Node) CommandItemOption
- func WithItemClass(class string) CommandItemOption
- func WithItemIcon(icon g.Node) CommandItemOption
- func WithOnSelect(expr string) CommandItemOption
- func WithShortcut(keys ...string) CommandItemOption
- func WithValue(value string) CommandItemOption
- type CommandItemProps
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Command ¶
Command creates a command menu container with search and keyboard navigation.
Example:
command.Command(
command.CommandInput(),
command.CommandList(
command.CommandGroup("Actions",
command.CommandItem("New File"),
),
),
)
func CommandDialog ¶
CommandDialog creates a command palette dialog that opens with ⌘K/Ctrl+K.
Example:
command.CommandDialog(
button.Button(g.Text("Open Command")),
command.CommandInput(),
command.CommandList(...),
)
func CommandEmpty ¶
CommandEmpty displays a message when no results are found.
Example:
command.CommandEmpty("No results found.")
func CommandGroup ¶
CommandGroup creates a group of related command items with an optional heading.
Example:
command.CommandGroup("Settings",
command.CommandItem("Profile"),
command.CommandItem("Billing"),
)
func CommandInput ¶
func CommandInput(opts ...CommandInputOption) g.Node
CommandInput creates a search input for the command menu.
Example:
command.CommandInput(
command.WithPlaceholder("Type a command..."),
)
func CommandItem ¶
func CommandItem(text string, opts ...CommandItemOption) g.Node
CommandItem creates a selectable command item.
Example:
command.CommandItem("New File",
command.WithItemIcon(icons.FilePlus()),
command.WithShortcut("⌘", "N"),
command.WithOnSelect("console.log('New file')"),
)
func CommandList ¶
CommandList creates a scrollable container for command items.
Example:
command.CommandList(
command.CommandEmpty("No results."),
command.CommandGroup("Items", ...),
)
func CommandSeparator ¶
CommandSeparator creates a visual separator between command groups.
Example:
command.CommandSeparator()
func CommandShortcut ¶
CommandShortcut displays keyboard shortcuts in a command item.
Example:
command.CommandShortcut("⌘", "K")
Types ¶
type CommandInputOption ¶
type CommandInputOption func(*CommandInputProps)
CommandInputOption is a functional option for configuring command input
func WithIcon ¶
func WithIcon(icon g.Node) CommandInputOption
WithIcon sets a custom icon for the input
func WithInputAttrs ¶
func WithInputAttrs(attrs ...g.Node) CommandInputOption
WithInputAttrs adds custom attributes to the input
func WithInputClass ¶
func WithInputClass(class string) CommandInputOption
WithInputClass adds custom classes to the input container
func WithPlaceholder ¶
func WithPlaceholder(text string) CommandInputOption
WithPlaceholder sets the input placeholder text
func WithShowClear ¶
func WithShowClear() CommandInputOption
WithShowClear shows the clear button when input has value
type CommandInputProps ¶
type CommandInputProps struct {
Placeholder string
Icon g.Node
ShowClear bool
Class string
Attrs []g.Node
}
CommandInputProps defines configuration for command input
type CommandItemOption ¶
type CommandItemOption func(*CommandItemProps)
CommandItemOption is a functional option for configuring command items
func WithDisabled ¶
func WithDisabled(disabled bool) CommandItemOption
WithDisabled disables the command item
func WithItemAttrs ¶
func WithItemAttrs(attrs ...g.Node) CommandItemOption
WithItemAttrs adds custom attributes to the item
func WithItemClass ¶
func WithItemClass(class string) CommandItemOption
WithItemClass adds custom classes to the item
func WithItemIcon ¶
func WithItemIcon(icon g.Node) CommandItemOption
WithItemIcon adds an icon to the command item
func WithOnSelect ¶
func WithOnSelect(expr string) CommandItemOption
WithOnSelect sets the Alpine expression to execute on selection
func WithShortcut ¶
func WithShortcut(keys ...string) CommandItemOption
WithShortcut adds keyboard shortcut display to the item
func WithValue ¶
func WithValue(value string) CommandItemOption
WithValue sets the search value for the item