Forms Core Stable

Autocomplete

A free-text field with a portalled panel of matching suggestions — any typed value is valid; the panel only ever helps finish it faster.

Preview

Installation

pnpm add fancy-ui-svelte
import { Autocomplete } from 'fancy-ui-svelte'

Usage

svelte
<script lang="ts">
  import { Autocomplete } from 'fancy-ui-svelte';
</script>

<Autocomplete />

Examples

Basic Usage

A city field with six candidate suggestions.

Min Length

Suggestions stay hidden until the third character.

With FormField

Wrapped in FormField — required and the error message driven by context.

Props

PropTypeDefaultDescription
suggestions *string[]-Candidate strings offered as the user types.
value string""The free-text value, bindable.
onValueChange (value: string) => void-Called with the new value on every keystroke.
onSelect (suggestion: string) => void-Called only when a suggestion is committed via click or Enter — never from plain typing.
placeholder string-Shown while the field is empty.
disabled booleanfalseBlocks focus and typing; excluded from form submission.
required booleanfalseNative required.
invalid booleanfalseDrives the error border and aria-invalid.
id string-Element id.
name string-Native name, read on form submission.
label string-Accessible name — for a control with no visible Label next to it.
minLength number1Characters required before suggestions appear.
maxSuggestions number8Maximum number of suggestions shown at once.
class string-Additional CSS classes.
ref HTMLInputElement | nullnullBindable reference to the input element.