DashboardSearch
Usage
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 and make sure it is registered before the DashboardSidebarButton:
<template>
<UDashboardGroup>
<UDashboardSearch />
<UDashboardSidebar>
<UDashboardSearchButton />
</UDashboardSidebar>
<slot />
</UDashboardGroup>
</template>
v-model:open
directive.Shortcut
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>
Color Mode
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>
API
Props
Prop | Default | Type |
---|---|---|
open |
| |
searchTerm |
| |
icon |
|
Icon for the search input. |
placeholder |
|
Placeholder for the search input. |
loading |
When | |
loadingIcon |
|
The icon when the |
shortcut |
|
Keyboard shortcut to open the search (used by |
groups |
| |
fuse |
|
Options for useFuse passed to the CommandPalette. |
colorMode |
|
When |
ui |
|
Slots
Slot | Type |
---|---|
empty |
|
close |
|
item |
|
item-leading |
|
item-label |
|
item-trailing |
|
Emits
Event | Type |
---|---|
update:open |
|
update:searchTerm |
|
Theme
export default defineAppConfig({
uiPro: {
dashboardSearch: {
slots: {
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({
uiPro: {
dashboardSearch: {
slots: {
modal: 'sm:max-w-3xl sm:h-[28rem]'
}
}
}
})
]
})