A searchable command menu. input$<inputId> is the value of the selected
item; input$<inputId>_event, a list of value and nonce, fires on every
activation, including a repeat of the same item. Compose contents with
shad_command_group(), shad_command_item(), and shad_command_separator().
Usage
shad_command(
inputId,
...,
placeholder = "Type a command or search...",
empty_text = "No results found.",
dialog = FALSE,
hotkey = dialog,
class = NULL
)
shad_command_group(label, ...)
shad_command_item(
value,
label = NULL,
icon = NULL,
shortcut = NULL,
keywords = NULL,
disabled = FALSE
)
shad_command_separator()Arguments
- inputId
Input id.
- ...
Command content (groups, items, separators).
- placeholder
Search-input placeholder.
- empty_text
Text shown when no item matches.
- dialog
If
TRUE, render the Cmd+K / Ctrl+K dialog variant.- hotkey
If
TRUE, bind themod+kopen hotkey (defaults todialog).- class
Extra CSS classes.
- label
Group heading, or item text.
- value
Item value reported on selection.
- icon
Optional leading icon.
- shortcut
Optional shortcut hint.
- keywords
Extra search terms (space-separated or a character vector).
- disabled
If
TRUE, the item is not selectable.
See also
Other shadshiny tier-3 components:
shad_accordion(),
shad_alert_dialog(),
shad_carousel(),
shad_collapsible(),
shad_command_palette(),
shad_context_menu(),
shad_dialog(),
shad_drawer(),
shad_dropdown_menu(),
shad_hover_card(),
shad_menu_parts,
shad_menubar(),
shad_message_scroller(),
shad_navigation_menu(),
shad_pagination(),
shad_popover(),
shad_resizable(),
shad_scroll_area(),
shad_sheet(),
shad_sidebar_layout(),
shad_tabs(),
shad_tooltip()
Examples
shad_command("cmd",
shad_command_group("Suggestions",
shad_command_item("calendar", "Calendar", keywords = "date schedule")))
#> <div class="shad-command" data-shad="command" id="cmd">
#> <div class="shad-command__header">
#> <svg class="shad-command__search-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/></svg>
#> <input class="shad-command__input" type="text" placeholder="Type a command or search..." aria-label="Search commands"/>
#> </div>
#> <div class="shad-command__list">
#> <div class="shad-command__empty">No results found.</div>
#> <div class="shad-command__group">
#> <div class="shad-command__group-heading">Suggestions</div>
#> <button type="button" class="shad-command__item" data-value="calendar" data-keywords="date schedule">Calendar</button>
#> </div>
#> </div>
#> </div>