Leave Yamada UI a star

Star
Yamada UIYamada UIv1.6.4

Autocomplete

Autocomplete is a component used to display suggestions in response to user text input.

Source@yamada-ui/autocomplete

The Autocomplete follows the WAI-ARIA - Combobox Pattern for accessibility.

If you are not using FormControl, set aria-label or aria-labelledby to Autocomplete.

<Autocomplete placeholder="キャラクターを選択" aria-label="キャラクター">
<AutocompleteOption value="孫悟空">孫悟空</AutocompleteOption>
<AutocompleteOption value="ベジータ">ベジータ</AutocompleteOption>
<AutocompleteOption value="フリーザ">フリーザ</AutocompleteOption>
</Autocomplete>
Copied!
<VStack gap="sm">
<Heading as="h3" id="label">
キャラクター
</Heading>
<Autocomplete placeholder="キャラクターを選択" aria-labelledby="label">
<AutocompleteOption value="孫悟空">孫悟空</AutocompleteOption>
<AutocompleteOption value="ベジータ">ベジータ</AutocompleteOption>
<AutocompleteOption value="フリーザ">フリーザ</AutocompleteOption>
</Autocomplete>
</VStack>
Copied!

Keyboard Navigation

KeyDescriptionState
ArrowUpFocuses the previous non-disabled item. If on the first item, focuses the last non-disabled item.-
ArrowDownFocuses the next non-disabled item. If on the last item, focuses the first non-disabled item.-
HomeFocuses the first non-disabled item.-
EndFocuses the last non-disabled item.-
Space, EnterSelects the focused item and closes the listbox.closeOnSelect={true}
EscapeCloses the listbox.closeOnEsc={true}

ARIA Roles and Attributes

ComponentRoles and AttributesUsage
AutocompleteField Internalrole="combobox"Indicates that this is a combobox.
aria-haspopup="listbox"Indicates that a listbox exists.
aria-autocomplete="list"Indicates that the component proposes a list of values related to the input value.
aria-activedescendantSet to the id of the focused item.
aria-expandedSet to "true" when the listbox is open, "false" when closed.
aria-controlsSet to the id of the related AutocompleteList when open, undefined when closed.
aria-readonlySet to "true" when isReadOnly is set.
aria-disabledSet to "true" when isDisabled is set.
aria-invalidSet to "true" when isInvalid is set.
aria-requiredSet to "true" when isRequired is set.
AutocompleteList Internalrole="listbox"Indicates that this is a listbox.
idThe id used to associate with AutocompleteField.
aria-hiddenSet to "true" when the listbox is open, "false" when closed.
AutocompleteOptionGrouprole="group"Indicates that this is a group.
aria-labelledbySets the id of the associated AutocompleteOptionGroupLabel.
AutocompleteOptionGroupLabel Internalrole="presentation"Indicates that this is a presentation.
idThe id used to associate with AutocompleteOptionGroup.
AutocompleteOptionrole="option"Indicates that this is an option.
idThe id used to associate with AutocompleteField.
aria-selectedSet to "true" when the option is selected, "false" when not selected.
aria-disabledSet to "true" when isDisabled is set.

Edit this page on GitHub

PreviousNativeSelectNextMultiAutocomplete