class Primer::Beta::AutoComplete

be used unless there is compelling reason not to. A placeholder is not a label.
However, please note that a visible label should almost always
* If you must use a non-visible label, set ‘is_label_visible` to `false`.
* `label_text` is required and visible by default.
Always set an accessible label to help the user interact with the component.
@accessibility
input field. This list is populated by server search results.
Use `AutoComplete` to provide a user with a list of selectable suggestions that appear when they type into the

def before_render

add `input` and `results` without needing to explicitly call them in the view
def before_render
  results(classes: "") unless results
  input(classes: "") unless input
end

def initialize(label_text:, src:, list_id:, input_id:, input_name: nil, is_label_visible: true, is_label_inline: false, with_icon: false, is_clearable: false, **system_arguments)

Parameters:
  • system_arguments (Hash) -- <%= link_to_system_arguments_docs %>
  • is_label_inline (Boolean) -- Controls if the label is inline. On smaller screens, label will always become stacked.
  • is_clearable (Boolean) -- Adds optional clear button.
  • is_label_visible (Boolean) -- Controls if the label is visible. If `false`, screen reader only text will be added.
  • with_icon (Boolean) -- Controls if a search icon is visible, defaults to `false`.
  • list_id (String) -- Id of the list element.
  • input_name (String) -- Optional name of the input element, defaults to `input_id` when not set.
  • input_id (String) -- Id of the input element.
  • src (String) -- The route to query.
  • label_text (String) -- The label of the input.

Other tags:
    Example: With custom classes for the results -
    Example: With custom classes for the input -
    Example: With clear button -
    Example: With icon and non-visible label -
    Example: With icon -
    Example: With non-visible label -
    Example: With inline label -
    Example: Default -
def initialize(label_text:, src:, list_id:, input_id:, input_name: nil, is_label_visible: true, is_label_inline: false, with_icon: false, is_clearable: false, **system_arguments)
  @label_text = label_text
  @list_id = list_id
  @input_id = input_id
  @input_name = input_name || input_id
  @is_label_visible = is_label_visible
  @with_icon = with_icon
  @is_clearable = is_clearable
  @label_classes = is_label_inline ? "autocomplete-label-inline" : "autocomplete-label-stacked"
  @system_arguments = deny_tag_argument(**system_arguments)
  @system_arguments[:tag] = "auto-complete"
  @system_arguments[:src] = src
  @system_arguments[:for] = list_id
end