sulaf
DocsComponents
X
Sections
  • Get Started
  • Installation
  • Components
  • Animations
    Soon
Components
  • Autocomplete
  • Show More
  • Typography
  • Code Block
    Soon
  • Code Snippet
    Soon
  • Guided Tour
    Soon
  • Meter
    Soon
  • Star Rating
    Soon
Animations
Soon

Autocomplete

PreviousNext

A searchable selection component with filtering capabilities, built on top of Reka UI Combobox.

Docs API Reference
<script setup lang="ts">
import { ref, computed } from 'vue'
import { useFilter } from 'reka-ui'
import { ChevronDownIcon, SearchIcon } from 'lucide-vue-next'
import {
  Autocomplete,
  AutocompleteContent,
  AutocompleteControl,
  AutocompleteEmpty,
  AutocompleteInput,
  AutocompleteItem,
  AutocompleteList,
  AutocompleteTrigger,
  AutocompleteClear,
  AutocompleteLabel,
  AutocompleteLoading,
  AutocompleteGroup,
} from '~/components/ui/autocomplete'

const items = ['Vue', 'React', 'Svelte', 'Angular', 'Solid', 'Nuxt', 'Next.js']

const searchTerm = ref('')
const value = ref<string>()
const isLoading = ref(false)

const { contains } = useFilter({ sensitivity: 'base' })

const filteredItems = computed(() => {
  if (!searchTerm.value) return items
  return items.filter(item => contains(item, searchTerm.value))
})

let timer: ReturnType<typeof setTimeout>
watch(searchTerm, newVal => {
  if (newVal) {
    isLoading.value = true
    clearTimeout(timer)
    timer = setTimeout(() => {
      isLoading.value = false
    }, 250)
  } else {
    isLoading.value = false
  }
})
</script>

<template>
  <Autocomplete v-model="value" v-model:search-term="searchTerm">
    <AutocompleteControl>
      <SearchIcon class="size-4 ms-2" />
      <AutocompleteInput placeholder="Search..." />

      <AutocompleteClear />

      <AutocompleteTrigger as-child>
        <div class="flex items-center pl-2">
          <ChevronDownIcon class="size-4 me-2" />
        </div>
      </AutocompleteTrigger>
    </AutocompleteControl>

    <AutocompleteContent>
      <AutocompleteLoading v-if="isLoading" />

      <template v-else>
        <AutocompleteEmpty>No framework found.</AutocompleteEmpty>

        <AutocompleteList>
          <AutocompleteGroup>
            <AutocompleteLabel>Framework</AutocompleteLabel>
            <AutocompleteItem v-for="item in filteredItems" :key="item" :value="item">
              {{ item }}
            </AutocompleteItem>
          </AutocompleteGroup>
        </AutocompleteList>
      </template>
    </AutocompleteContent>
  </Autocomplete>
</template>

Installation

pnpm dlx sulaf@latest add autocomplete

API Reference

The Autocomplete component uses Reka UI's Combobox primitive under the hood, but introduces a few custom abstractions, models, and styling defaults.

Autocomplete (Root)

The root component extends all ComboboxRoot properties and adds semantic handling for the search input state.

PropTypeDefaultDescription
v-model:search-termstring''Exposes the direct value of the AutocompleteInput. By binding to this, you can filter your own item lists dynamically outside the component.

Last updated on April 14, 2026

ComponentsShow More

On This Page

InstallationAPI ReferenceAutocomplete (Root)
© 2026 - Built with shadcn-vue . The source code is available on GitHub.