AutoComplete
Description
Use AutoComplete to provide a user with a list of selectable suggestions that appear when they type into the
input field. This list is populated by server search results.
Accessibility
Always set an accessible label to help the user interact with the component.
label_textis required and visible by default.- If you must hide the label, set
visually_hide_labeltotrue. However, please note that a visible label should almost always be used unless there is compelling reason not to. A placeholder is not a label.
Arguments
| Name | Default | Description |
|---|---|---|
label_text | StringThe label of the input. | |
src | StringThe route to query. | |
input_id | StringId of the input element. | |
input_name | StringOptional name of the input element, defaults to | |
list_id | StringId of the list element. | |
visually_hide_label | BooleanControls if the label is visible. If | |
show_clear_button | BooleanAdds optional clear button. | |
system_arguments | Hash | |
size | HashInput size can be small, medium (default), or large | |
full_width | BooleanInput can be full-width or fit to content | |
width | StringOptional parameter to set max width of results list. One of | |
disabled | BooleanDisabled input | |
invalid | BooleanInvalid input | |
placeholder | StringThe placeholder text displayed within the input | |
inset | Booleansubtle input background color | |
monospace | Booleanmonospace input font family |
Slots
results
Customizable results list.
| Name | Default | Description |
|---|---|---|
system_arguments | Hash |
leading_visual
Leading visual.
leading_visual_iconfor aPrimer::Beta::Octicon.
| Name | Default | Description |
|---|---|---|
system_arguments | HashSame arguments as |
input
Customizable input used to search for results. It is preferred to use this slot sparingly - it will be created by default if not explicity added.
| Name | Default | Description |
|---|---|---|
system_arguments | Hash |
AutoComplete::Item
Use AutoCompleteItem to list results of an auto-completed search.
Arguments
| Name | Default | Description |
|---|---|---|
value | StringValue of the item. | |
selected | BooleanWhether the item is selected. | |
disabled | BooleanWhether the item is disabled. | |
description_variant | HashChanges the description style. Allowed values are :inline, :block | |
description | StringDisplay description text below label | |
system_arguments | Hash |
Slots
leading_visual
The leading visual rendered before the link.
| Name | Default | Description |
|---|---|---|
kwargs | HashThe arguments accepted by |
trailing_visual
The trailing visual rendered after the link.
| Name | Default | Description |
|---|---|---|
kwargs | HashThe arguments accepted by |
description
Optional description
| Name | Default | Description |
|---|---|---|
system_arguments | Hash |
AutoComplete::NoResultItem
Slots
leading_visual
The leading visual rendered before the link.
| Name | Default | Description |
|---|---|---|
kwargs | HashThe arguments accepted by |
trailing_visual
The trailing visual rendered after the link.
| Name | Default | Description |
|---|---|---|
kwargs | HashThe arguments accepted by |
description
Optional description
| Name | Default | Description |
|---|---|---|
system_arguments | Hash |