The DashboardSearch component extends the CommandPalette component, so you can pass any property such as icon, placeholder, etc.
Use it inside the default slot of the DashboardGroup component:
<template>
<UDashboardGroup>
<UDashboardSidebar>
<UDashboardSearchButton />
</UDashboardSidebar>
<UDashboardSearch />
<slot />
</UDashboardGroup>
</template>
v-model:open directive.Use the shortcut prop to change the shortcut used in defineShortcuts to open the ContentSearch component. Defaults to meta_k ( K).
<template>
<UDashboardSearch
v-model:search-term="searchTerm"
shortcut="meta_k"
:groups="groups"
:fuse="{ resultLimit: 42 }"
/>
</template>
By default, a group of commands will be added to the command palette so you can switch between light and dark mode. This will only take effect if the colorMode is not forced in a specific page which can be achieved through definePageMeta:
<script setup lang="ts">
definePageMeta({
colorMode: 'dark'
})
</script>
You can disable this behavior by setting the color-mode prop to false:
<template>
<UDashboardSearch
v-model:search-term="searchTerm"
:color-mode="false"
:groups="groups"
:fuse="{ resultLimit: 42 }"
/>
</template>
| Prop | Default | Type |
|---|---|---|
icon | appConfig.ui.icons.search | string | objectThe icon displayed in the input. |
placeholder | t('commandPalette.placeholder') | stringThe placeholder text for the input. |
autofocus | true | boolean Automatically focus the input when component is mounted. |
loading | boolean When | |
loadingIcon | appConfig.ui.icons.loading | string | objectThe icon when the |
close | true | boolean | Partial<ButtonProps> Display a close button in the input (useful when inside a Modal for example).
|
closeIcon | appConfig.ui.icons.close | string | objectThe icon displayed in the close button. |
shortcut | 'meta_k' | stringKeyboard shortcut to open the search (used by |
groups | CommandPaletteGroup<CommandPaletteItem>[] | |
fuse | {} | UseFuseOptions<CommandPaletteItem>Options for useFuse passed to the CommandPalette. |
colorMode | true | boolean When |
title | string | |
description | string | |
overlay | true | boolean Render an overlay behind the modal. |
transition | true | boolean Animate the modal when opening or closing. |
content | DialogContentProps & Partial<EmitsToProps<DialogContentImplEmits>>The content of the modal.
| |
dismissible | true | boolean When |
fullscreen | false | boolean When |
modal | boolean The modality of the dialog When set to | |
portal | true | string | false | true | HTMLElementRender the modal in a portal. |
open | false | boolean |
searchTerm | '' | string |
ui | { modal?: ClassNameValue; input?: ClassNameValue; } & { root?: ClassNameValue; input?: ClassNameValue; close?: ClassNameValue; back?: ClassNameValue; content?: ClassNameValue; footer?: ClassNameValue; viewport?: ClassNameValue; group?: ClassNameValue; empty?: ClassNameValue; label?: ClassNameValue; item?: ClassNameValue; itemLeadingIcon?: ClassNameValue; itemLeadingAvatar?: ClassNameValue; itemLeadingAvatarSize?: ClassNameValue; itemLeadingChip?: ClassNameValue; itemLeadingChipSize?: ClassNameValue; itemTrailing?: ClassNameValue; itemTrailingIcon?: ClassNameValue; itemTrailingHighlightedIcon?: ClassNameValue; itemTrailingKbds?: ClassNameValue; itemTrailingKbdsSize?: ClassNameValue; itemWrapper?: ClassNameValue; itemLabel?: ClassNameValue; itemDescription?: ClassNameValue; itemLabelBase?: ClassNameValue; itemLabelPrefix?: ClassNameValue; itemLabelSuffix?: ClassNameValue; }
|
| Slot | Type |
|---|---|
empty | { searchTerm?: string | undefined; } |
footer | { ui: object; } |
back | { ui: object; } |
close | { ui: object; } |
item | { item: CommandPaletteItem; index: number; ui: object; } |
item-leading | { item: CommandPaletteItem; index: number; ui: object; } |
item-label | { item: CommandPaletteItem; index: number; ui: object; } |
item-description | { item: CommandPaletteItem; index: number; ui: object; } |
item-trailing | { item: CommandPaletteItem; index: number; ui: object; } |
content | { close: () => void; } |
| Event | Type |
|---|---|
update:open | [value: boolean] |
update:searchTerm | [value: string] |
When accessing the component via a template ref, you can use the following:
| Name | Type |
|---|---|
commandPaletteRef | Ref<InstanceType<typeof UCommandPalette> | null> |
export default defineAppConfig({
ui: {
dashboardSearch: {
slots: {
modal: '',
input: '[&>input]:text-base/5'
},
variants: {
fullscreen: {
false: {
modal: 'sm:max-w-3xl sm:h-[28rem]'
}
}
}
}
}
})
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import ui from '@nuxt/ui/vite'
export default defineConfig({
plugins: [
vue(),
ui({
ui: {
dashboardSearch: {
slots: {
modal: '',
input: '[&>input]:text-base/5'
},
variants: {
fullscreen: {
false: {
modal: 'sm:max-w-3xl sm:h-[28rem]'
}
}
}
}
}
})
]
})