Documentation
¶
Overview ¶
Package command provides a shadcn/ui-style Command: a palette that opens over the window to run a command by name, as ⌘K does. A field filters the commands by their labels and keywords as you type, the arrows move the choice down the list that remains, and Enter or a click runs the chosen one.
command.Command(c, command.Props{
Open: &open,
Items: []command.Item{
{Label: "New file", Keywords: []string{"create"}, OnSelect: app.newFile},
},
})
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Item ¶
type Item struct {
// Label is the text of the command.
Label string
// Keywords are the extra words a search matches, such as synonyms
// of the command.
Keywords []string
// Icon is the shape of the command, an SVG in currentColor; nil
// for none.
Icon *ui.SVG
// OnSelect runs when the command is chosen.
OnSelect func()
}
Item is one command of the palette.
type Props ¶
type Props struct {
// Open is the bool that shows and hides the palette; the backdrop
// and Escape set it to false.
Open *bool
// State is where the palette is, for the app to keep.
State *State
// Items are the commands offered, in order.
Items []Item
}
Props describes the palette to draw.
Click to show internal directories.
Click to hide internal directories.