v2.15.0

DashboardSearch

Готовая командная палитра CommandPalette для вашего дашборда.

Использование

Компонент DashboardSearch расширяет CommandPalette, поэтому ему можно передать любое свойство: icon, placeholder и другие.

Используйте его в слоте по умолчанию компонента DashboardGroup:

layouts/dashboard.vue
<template>
  <B24DashboardGroup>
    <B24DashboardSidebar>
      <B24DashboardSearchButton />
    </B24DashboardSidebar>

    <B24DashboardSearch />

    <slot />
  </B24DashboardGroup>
</template>
Открыть палитру можно сочетанием CtrlK, компонентом DashboardSearchButton или директивой v-model:open.

Сочетание клавиш

Пропс shortcut меняет сочетание клавиш, которое defineShortcuts использует для открытия DashboardSearch. По умолчанию meta_k (Ctrl K).

app.vue
<template>
  <B24DashboardSearch
    v-model:search-term="searchTerm"
    shortcut="meta_k"
    :groups="groups"
    :fuse="{ resultLimit: 42 }"
  />
</template>

Цветовая схема

По умолчанию в палитру добавляется группа команд для переключения между светлой и тёмной темой. Это работает, только если colorMode не зафиксирован на конкретной странице через definePageMeta:

pages/index.vue
<script setup lang="ts">
definePageMeta({
  colorMode: 'dark'
})
</script>

Отключить эту группу можно пропсом color-mode со значением false:

app.vue
<template>
  <B24DashboardSearch
    v-model:search-term="searchTerm"
    :color-mode="false"
    :groups="groups"
    :fuse="{ resultLimit: 42 }"
  />
</template>

API

Пропсы

Prop Default Type
size'md' "sm" | "md" | "xs" | "lg" | "xss" | "xl"
closetrueboolean | Omit<ButtonProps, LinkPropsKeys>

Display a close button in the input (useful when inside a Modal for example). { size: 'sm', color: 'air-tertiary-no-accent' }

inputtrueboolean | Omit<InputProps<AcceptableValue, ModelModifiers>, "modelValue" | "defaultValue">

Configure the input or hide it with false. { fixed: true }

shortcut'meta_k' string

Keyboard shortcut to open the search (used by defineShortcuts)

fuse{ fuseOptions: { ignoreLocation: true, useTokenSearch: true, threshold: 0.1, keys: ['label', 'description', 'suffix'] }, resultLimit: 12, matchAllWhenSearchEmpty: true } UseFuseOptions<CommandPaletteItem>

Options for useFuse passed to the CommandPalette.

searchDelay100 number

Delay (in milliseconds) before the search term is passed to Fuse (debounced). Useful for large datasets where running fuzzy search on every keystroke is the bottleneck — the input stays responsive while Fuse only re-runs after typing settles. Set to 0 to disable.

colorModetrueboolean

When true, the theme command will be added to the groups.

title string
transitiontrueboolean

Animate the modal when opening or closing.

description string
overlaytrueboolean

Render an overlay behind the modal.

content DialogContentProps & Partial<EmitsToProps<DialogContentImplEmits>>

The content of the modal.

dismissiblefalseboolean

When false, the modal will not close when clicking outside or pressing escape.

fullscreenfalseboolean

When true, the modal will take up the full screen.

modalboolean

The modality of the dialog When set to true,
interaction with outside elements will be disabled and only dialog content will be visible to screen readers.

portaltrue string | false | true | HTMLElement

Render the modal in a portal.

unmountOnHidetrueboolean

When set to false, the dialog content will not be unmounted when closed, but instead hidden with CSS.
Useful for SEO or when you want to improve performance by not remounting the component on every open.

iconicons.searchIconComponent

The icon displayed in the input. Set to false to hide the icon.

trailingIconicons.searchIconComponent

The icon displayed on the right side of the input.

loadingboolean

When true, the loading icon will be displayed.

autofocustrueboolean

Automatically focus the input when component is mounted.

disabledboolean

When true, prevents the user from interacting with listbox

selectedIconicons.checkIconComponent

The icon displayed when an item is selected.

childrenIconicons.chevronRightIconComponent

The icon displayed when an item has children.

placeholdert('commandPalette.placeholder') string

The placeholder text for the input.

closeIconicons.closeIconComponent

The icon displayed in the close button.

backtrueboolean | Omit<ButtonProps, LinkPropsKeys>

Display a button to navigate back in history. { color: 'air-tertiary-accent' }

backIconicons.arrowLeftIconComponent

The icon displayed in the back button.

highlightOnHoverboolean

When true, hover over item will trigger highlight

loopboolean

When true, keyboard navigation will loop from last item to first, and vice versa.

labelKey'label' string

The key used to get the label from the item.

descriptionKey'description' string

The key used to get the description from the item.

preserveGroupOrderfalseboolean

Whether to preserve the order of groups as defined in the groups prop when filtering. When false, groups will appear based on item matches.

virtualizefalseboolean | { overscan?: number ; estimateSize?: number | ((index: number) => number) | undefined; } | undefined

Enable virtualization for large lists. Note: when enabled, all groups are flattened into a single list due to a limitation of Reka UI (https://github.com/unovue/reka-ui/issues/1885).

groups CommandPaletteGroup<CommandPaletteItem>[]
openfalseboolean
searchTerm'' string
b24ui { modal?: SlotClass; input?: SlotClass; } & { root?: SlotClass; input?: SlotClass; close?: SlotClass; back?: SlotClass; content?: SlotClass; footer?: SlotClass; viewport?: SlotClass; group?: SlotClass; empty?: SlotClass; label?: SlotClass; item?: SlotClass; itemLeadingIcon?: SlotClass; itemLeadingAvatar?: SlotClass; itemLeadingAvatarSize?: SlotClass; itemLeadingChip?: SlotClass; itemLeadingChipSize?: SlotClass; itemTrailing?: SlotClass; itemTrailingIcon?: SlotClass; itemTrailingHighlightedIcon?: SlotClass; itemTrailingKbds?: SlotClass; itemTrailingKbdsSize?: SlotClass; itemWrapper?: SlotClass; itemLabel?: SlotClass; itemLabelBase?: SlotClass; itemLabelPrefix?: SlotClass; itemLabelSuffix?: SlotClass; itemDescription?: SlotClass; }

Слоты

Slot Type
empty{ searchTerm?: string | undefined; }
footer{ b24ui: object; }
back{ b24ui: object; }
close{ b24ui: object; }
item{ item: CommandPaletteItem; index: number; b24ui: object; }
item-leading{ item: CommandPaletteItem; index: number; b24ui: object; }
item-label{ item: CommandPaletteItem; index: number; b24ui: object; }
item-description{ item: CommandPaletteItem; index: number; b24ui: object; }
item-trailing{ item: CommandPaletteItem; index: number; b24ui: object; }
group-label{ group: CommandPaletteGroup<CommandPaletteItem>; label: string; b24ui: object; }
content{ close: () => void; }

События

Event Type
update:open[value: boolean]
update:searchTerm[value: string]

Доступ через ref

Через ref шаблона доступно:

NameType
commandPaletteRefRef<InstanceType<typeof B24CommandPalette> | null>

Тема

https://github.com/bx-shef/b24-ui/tree/main/src/theme/dashboard-search.ts
export default {
  slots: {
    modal: 'p-0 pt-0 pb-[10px]',
    input: ''
  },
  variants: {
    fullscreen: {
      false: {
        modal: 'sm:max-w-[768px] h-full sm:h-[436px]'
      }
    },
    size: {
      xss: {},
      xs: {},
      sm: {},
      md: {},
      lg: {},
      xl: {}
    }
  },
  defaultVariants: {
    size: 'md'
  }
}