N/A

DocsSearchModal

Add a lightweight local search modal to Nuxt documentation interfaces.

Installation

pnpm dlx shadcn-vue@latest add "https://ui.stackhacker.io/r/docs-search-modal.json"

Usage

<script setup lang="ts">
import { DocsSearchModal, type DocsSearchItem } from '@/components/docs-search-modal'

const open = ref(false)

const items: DocsSearchItem[] = [
  {
    title: 'Introduction',
    description: 'Start here to understand the docs structure.',
    href: '/docs/introduction',
    section: 'Getting Started',
    content: 'overview installation usage'
  }
]
</script>

<template>
  <button type="button" @click="open = true">
    Search
  </button>

  <DocsSearchModal v-model:open="open" :items="items" />
</template>

App-Owned Data

DocsSearchModal owns the modal UI, keyboard shortcut, local filtering, and result rendering boundary. Your app owns the search data.

Map static docs, Nuxt Content results, or any other source into DocsSearchItem[] before passing it to the component.

import type { DocsSearchItem } from '@/components/docs-search-modal'

const items: DocsSearchItem[] = pages.map(page => ({
  title: page.title,
  description: page.description,
  href: page.path,
  section: page.category,
  content: page.bodyText
}))

The component intentionally does not crawl pages, query Nuxt Content, call a search provider, rank results, or persist recent searches.

Examples

Default

API Reference

Props

PropTypeDefaultDescription
itemsDocsSearchItem[][]Searchable items supplied by your app.
placeholderstring'Search documentation...'Search input placeholder.
searchLabelstring'Search documentation'Accessible label for the dialog and search input.
emptyTextstring'No pages available.'Text shown when no query is entered and there are no items.
noResultsTextstring'No results found.'Text shown when a query has no matches.
shortcutbooleantrueEnable Cmd+K / Ctrl+K to open the modal.
classstringAdditional CSS classes for the modal panel.

Models

ModelTypeDescription
openbooleanControls whether the modal is open.

Slots

SlotPropsDescription
item{ item, query }Custom result renderer.

Types

interface DocsSearchItem {
  title: string
  href: string
  description?: string
  section?: string
  content?: string
}