Nuxt UI v3 is officially released!

Components

CommandPalette

Add a customizable command palette to your app.

Usage

Use a v-model to display a searchable and selectable list of commands.

Wade Cooper
Arlene Mccoy
Devon Webb
Tom Cook
Tanya Fox
Hellen Schmidt
{
  "message": "You should use slots with <ContentRenderer>",
  "value": {},
  "excerpt": false,
  "tag": "div"
}

You can put a CommandPalette anywhere you want but it's most commonly used inside of a modal.

{
  "message": "You should use slots with <ContentRenderer>",
  "value": {},
  "excerpt": false,
  "tag": "div"
}

You can pass multiple groups of commands to the component. Each group will be separated by a divider and will display a label.

Without a v-model, you can also listen on @update:model-value to navigate to a link or do something else when a command is clicked.

Recent searches

benjamincanac
Add new file
Add new folder
Add hashtag
Add label
{
  "message": "You should use slots with <ContentRenderer>",
  "value": {},
  "excerpt": false,
  "tag": "div"
}

Icon

Use any icon from Iconify by setting the icon prop by using this pattern: i-{collection_name}-{icon_name}.

Use the selected-icon prop to set a different icon or change it globally in ui.commandPalette.default.selectedIcon. Defaults to i-heroicons-check-20-solid.

{
  "message": "You should use slots with <ContentRenderer>",
  "value": {},
  "excerpt": false,
  "tag": "div"
}

Loading

Use the loading prop to show a loading icon.

Use the loading-icon prop to set a different icon or change it globally in ui.commandPalette.default.loadingIcon. Defaults to i-heroicons-arrow-path-20-solid.

{
  "message": "You should use slots with <ContentRenderer>",
  "value": {},
  "excerpt": false,
  "tag": "div"
}

Placeholder

Use the placeholder prop to change the input placeholder

{
  "message": "You should use slots with <ContentRenderer>",
  "value": {},
  "excerpt": false,
  "tag": "div"
}

Close

Use the close-button prop to display a close button on the right side of the input.

You can pass all the props of the Button component to customize it through the close-button prop or globally through ui.commandPalette.default.closeButton.

{
  "message": "You should use slots with <ContentRenderer>",
  "value": {},
  "excerpt": false,
  "tag": "div"
}

Empty

An empty state will be displayed when there are no results.

Use the empty-state prop to customize the icon and label or change them globally in ui.commandPalette.default.emptyState.

You can also set it to null to hide the empty state.

We couldn't find any items.

{
  "message": "You should use slots with <ContentRenderer>",
  "value": {},
  "excerpt": false,
  "tag": "div"
}

The CommandPalette component takes care of the full-text search for you with Fuse.js. You can pass all the options of Fuse.js through the fuse prop.

When searching for a command, the component will look for a label property on the command by default. You can customize this behavior by overriding the command-attribute prop. This will also affect the display of the command.

You can also highlight the matches in the command by setting the fuse.fuseOptions.includeMatches to true. The CommandPalette component automatically takes care of the highlighting for you.

<template>
  <UCommandPalette
    command-attribute="title"
    :fuse="{
      fuseOptions: {
        ignoreLocation: true,
        includeMatches: true,
        threshold: 0,
        keys: ['title', 'description', 'children.children.value', 'children.children.children.value']
      },
      resultLimit: 10
    }"
  />
</template>
Try it yourself in this documentation's search by pressing K.

You can also pass an async function to the search property of a group to perform an async search. The function will receive the query as its first argument and should return an array of commands.

We couldn't find any items.

{
  "message": "You should use slots with <ContentRenderer>",
  "value": {},
  "excerpt": false,
  "tag": "div"
}
The loading state will automatically be enabled when a search function is loading. You can disable this behavior by setting the loading-icon prop to null or globally in ui.commandPalette.default.loadingIcon.

You can also pass a function to the filter property of a group to filter displayed commands after the search happened. The function will receive the query as its first argument, the array of commands as second argument and should return an array of commands.

Arlene Mccoy
Tom Cook
Hellen Schmidt
Mason Heaney
Emil Schaefer
{
  "message": "You should use slots with <ContentRenderer>",
  "value": {},
  "excerpt": false,
  "tag": "div"
}

Slots

<group>-icon

Use the #<group>-icon slot to override the left command content which display by default the icon, avatar and chip.

<group>-command

Use the #<group>-command slot to override the command content which display by default the prefix, suffix and label (customizable through the command-attribute prop).

<group>-active

Use the #<group>-active slot to override the right command content (when hovered) which display by default the active field of the group if provided.

<group>-inactive

Use the #<group>-inactive slot to override the right command content (when not hovered) which display by default the inactive field of the group if provided or the shortcuts of the command.

The 4 slots above will have access to the group, command, active and selected properties in the slot scope.

empty-state

Use the #empty-state slot to customize the empty state.

Nothing here!
{
  "message": "You should use slots with <ContentRenderer>",
  "value": {},
  "excerpt": false,
  "tag": "div"
}

Props

icon
string
config.default.icon
ui
{ wrapper?: string; container?: string; input?: DeepPartial<{ wrapper: string; base: string; padding: string; height: string; size: string; icon: { base: string; loading: string; size: string; padding: string; }; closeButton: { base: string; padding: string; }; }, any>; emptyState?: DeepPartial<{ wrapper: string; label: string; queryLabel: string; icon: string; }, any>; group?: DeepPartial<{ wrapper: string; label: string; container: string; command: { base: string; active: string; inactive: string; label: string; prefix: string; suffix: string; container: string; icon: { base: string; active: string; inactive: string; }; selectedIcon: { base: string; }; avatar: { base: string; size: AvatarSize; }; chip: { base: string; }; disabled: string; shortcuts: string; }; active: string; inactive: string; }, any>; default?: DeepPartial<{ icon: string; loadingIcon: string; emptyState: { icon: string; label: string; queryLabel: string; }; closeButton: any; selectedIcon: string; }, any>; } & { [key: string]: any; } & { strategy?: Strategy; }
{}
modelValue
string | number | Record<string, any> | unknown[]
null
placeholder
string
"Search..."
loadingIcon
string
config.default.loadingIcon
by
string
"id"
selectedIcon
string
config.default.selectedIcon
debounce
number
200
emptyState
{ icon: string; label: string; queryLabel: string; }
config.default.emptyState
groupAttribute
string
"label"
commandAttribute
string
"label"
groups
Group[]
[]
closeButton
Button
config.default.closeButton as unknown as Button
fuse
UseFuseOptions<Command>
{}
onClose
(...args: any[]) => any
onUpdate:modelValue
(...args: any[]) => any
nullable
boolean
false
loading
boolean
false
multiple
boolean
false
searchable
boolean
true
autoselect
boolean
true
autoclear
boolean
true

API

When accessing the component via a template ref, you can use the following:

query
string

The current query.

updateQuery (query)

Updates the current query.

results
ComputedRef<FuseResult<Command>[]>

The results exposed by useFuse.

comboboxApi

The Combobox API exposed by Headless UI.

Config

{
  "message": "You should use slots with <ContentRenderer>",
  "value": {},
  "excerpt": false,
  "tag": "div"
}

Example

Here are a few examples illustrating how you can customize the appearance of the CommandPalette component by utilizing its ui prop.

Algolia

No recent searches

Take a look at the component!

Raycast

Suggestions

Linear
Application
Figma
Application
Slack
Application
YouTube
Application
GitHub
Application

Commands

Clipboard History
Command
Import Extension
Command
Manage Extensions
Command
Take a look at the component!