Dinachi

Autocomplete

A text input with dynamic suggestions that helps users find and select values quickly.

#Installation

npx @dinachi/cli@latest add autocomplete

#Usage

tsx
import {
  Autocomplete,
  AutocompleteInput,
  AutocompleteTrigger,
  AutocompleteClear,
  AutocompleteContent,
  AutocompleteList,
  AutocompleteItem,
  AutocompleteGroup,
  AutocompleteGroupLabel,
  AutocompleteEmpty,
  AutocompleteStatus,
  AutocompleteSeparator,
} from "@/components/ui/autocomplete"

#Examples

Default Autocomplete

A text input with type-ahead suggestions

Autocomplete with Groups

Autocomplete with grouped suggestion categories

Autocomplete with Clear

Autocomplete with a clear button to reset input

#API Reference

#Autocomplete (Root)

PropTypeDefaultDescription
itemsT[] | GroupedItems[]The items to display. Can be a flat array or an array of groups (objects with value and items properties).
mode'list' | 'both' | 'inline' | 'none''list'Controls filtering and inline autocompletion. 'list' filters items, 'both' filters and shows inline completion, 'inline' shows inline completion without filtering, 'none' disables both.
openOnInputClickbooleanfalseWhether the popup opens when clicking the input.
valuestringThe controlled input value.
defaultValuestringThe uncontrolled initial input value.
onValueChange(value: string, eventDetails) => voidCallback fired when the input value changes.
onOpenChange(open: boolean, eventDetails) => voidCallback fired when the popup is opened or closed.
autoHighlightboolean | 'always'falseWhether the first matching item is highlighted automatically.
keepHighlightbooleanfalseWhether the highlighted item is preserved when the pointer leaves the list.
disabledbooleanfalseWhether the component should ignore user interaction.

#AutocompleteItem

PropTypeDefaultDescription
valueanyThe value of the item. Required.
insetbooleanfalseAdds additional left padding for nested item layouts.

#AutocompleteGroup

PropTypeDefaultDescription
itemsany[]Items to be rendered within this group. Child Collection components will use these items.

#Other Parts

PropTypeDefaultDescription
AutocompleteContent.portalbooleantrueWhether to render in a portal. Set to false inside Dialog or Drawer.
AutocompleteTrigger.childrenReact.ReactNodeOptional custom trigger content. Defaults to a chevron icon.
AutocompleteClear.childrenReact.ReactNodeOptional custom clear content. Defaults to an X icon.