Logo

AutoComplete

AutoComplete is a searchable dropdown input that allows users to type and filter through options, with support for single or multiple selections. Unlike a basic Select, it provides type-ahead functionality and can allow users to create new options.
Key features:
  • Type-ahead filtering: Users can type to narrow down options in real-time
  • Multi-select support: Set multi="true" to allow selecting multiple items
  • Custom option creation: Enable creatable="true" to let users add new options
  • Rich customization: Use optionTemplate to create complex option layouts

Using AutoComplete

<App>
  <AutoComplete>
    <Option value="1" label="Bruce Wayne" />
    <Option value="2" label="Clark Kent" enabled="false" />
    <Option value="3" label="Diana Prince" />
  </AutoComplete>
</App>
Example: Using AutoComplete
<App>
  <AutoComplete>
    <Option value="1" label="Bruce Wayne" />
    <Option value="2" label="Clark Kent" enabled="false" />
    <Option value="3" label="Diana Prince" />
  </AutoComplete>
</App>
Context variables available during execution:
  • $item: This context value represents an item when you define an option item template. Use $item.value and $item.label to refer to the value and label of the particular option.

Properties

autoFocus (default: false)

If this property is set to true, the component gets the focus automatically when displayed.

creatable (default: false)

This property allows the user to create new items that are not present in the list of options.
This property sets the height of the dropdown list.

emptyListTemplate

This property defines the template to display when the list of options is empty.
<App>
  <AutoComplete>
    <property name="emptyListTemplate">
      <Text>No options found</Text>
    </property>
  </AutoComplete>
</App>
Example: emptyListTemplate
<App>
  <AutoComplete>
    <property name="emptyListTemplate">
      <Text>No options found</Text>
    </property>
  </AutoComplete>
</App>

enabled (default: true)

This boolean property value indicates whether the component responds to user events (true) or not (false).

initialValue

This property sets the component's initial value.

label

This property sets the label of the component. If not set, the component will not display a label.

labelBreak (default: true)

This boolean value indicates whether the AutoComplete label can be split into multiple lines if it would overflow the available label width.

labelPosition

Places the label at the given position of the component.
Available values:
ValueDescription
startThe left side of the input (left-to-right) or the right side of the input (right-to-left)
endThe right side of the input (left-to-right) or the left side of the input (right-to-left)
topThe top of the input
bottomThe bottom of the input

labelWidth

This property sets the width of the AutoComplete component's label. If not defined, the label's width will be determined by its content and the available space.

maxLength

This property sets the maximum length of the input it accepts.

multi (default: false)

The true value of the property indicates if the user can select multiple items.
    <App>
      <AutoComplete multi="true">
        <Option value="1" label="Bruce Wayne" />
        <Option value="2" label="Clark Kent" />
        <Option value="3" label="Diana Prince" />
        <Option value="4" label="Barry Allen" />
        <Option value="5" label="Hal Jordan" />
      </AutoComplete>
    </App>
Example: multi
    <App>
      <AutoComplete multi="true">
        <Option value="1" label="Bruce Wayne" />
        <Option value="2" label="Clark Kent" />
        <Option value="3" label="Diana Prince" />
        <Option value="4" label="Barry Allen" />
        <Option value="5" label="Hal Jordan" />
      </AutoComplete>
    </App>

optionTemplate

This property enables the customization of list items. To access the attributes of a list item use the $item context variable.
<App>
  <AutoComplete multi="true">
    <property name="optionTemplate">
      <Text textAlign="center" color="red">{$item.label}</Text>
    </property>
    <Option value="1" label="Bruce Wayne" />
    <Option value="2" label="Clark Kent" />
    <Option value="3" label="Diana Prince" />
  </AutoComplete>
</App>
Example: optionTemplate
<App>
  <AutoComplete multi="true">
    <property name="optionTemplate">
      <Text textAlign="center" color="red">{$item.label}</Text>
    </property>
    <Option value="1" label="Bruce Wayne" />
    <Option value="2" label="Clark Kent" />
    <Option value="3" label="Diana Prince" />
  </AutoComplete>
</App>

placeholder

An optional placeholder text that is visible in the input field when its empty.

readOnly (default: false)

Set this property to true to disallow changing the component value.

required (default: false)

Set this property to true to indicate it must have a value before submitting the containing form.

validationStatus (default: "none")

This property allows you to set the validation status of the input component.
Available values:
ValueDescription
validVisual indicator for an input that is accepted
warningVisual indicator for an input that produced a warning
errorVisual indicator for an input that produced an error

Events

didChange

This event is triggered when value of AutoComplete has changed.

gotFocus

This event is triggered when the AutoComplete has received the focus.

lostFocus

This event is triggered when the AutoComplete has lost the focus.

Exposed Methods

focus

This method focuses the AutoComplete component.
Signature: focus()

setValue

This API allows you to set the value of the component. If the value is not valid, the component will not update its internal state.
Signature: setValue(value: any)
  • value: The value to set.

value

This API allows you to get or set the value of the component. If no value is set, it will retrieve undefined.
Signature: get value(): any

Styling

Theme Variables

VariableDefault Value (Light)Default Value (Dark)
backgroundColor-AutoComplete--disablednonenone
backgroundColor-AutoComplete-badge$color-primary-500$color-primary-500
backgroundColor-AutoComplete-badge$color-primary-500$color-primary-500
backgroundColor-AutoComplete-badge--active$color-primary-500$color-primary-500
backgroundColor-AutoComplete-badge--active$color-primary-500$color-primary-500
backgroundColor-AutoComplete-badge--hover$color-primary-400$color-primary-400
backgroundColor-AutoComplete-badge--hover$color-primary-400$color-primary-400
backgroundColor-AutoComplete-defaultnonenone
backgroundColor-AutoComplete-default--hovernonenone
backgroundColor-AutoComplete-errornonenone
backgroundColor-AutoComplete-error--hovernonenone
backgroundColor-AutoComplete-successnonenone
backgroundColor-AutoComplete-success--hovernonenone
backgroundColor-AutoComplete-warningnonenone
backgroundColor-AutoComplete-warning--hovernonenone
backgroundColor-item-AutoComplete$backgroundColor-dropdown-item$backgroundColor-dropdown-item
backgroundColor-item-AutoComplete--active$backgroundColor-dropdown-item--active$backgroundColor-dropdown-item--active
backgroundColor-item-AutoComplete--hover$backgroundColor-dropdown-item--active$backgroundColor-dropdown-item--active
backgroundColor-menu-AutoComplete$backgroundColor-primary$backgroundColor-primary
backgroundColor-menu-AutoComplete$backgroundColor-primary$backgroundColor-primary
border-AutoCompletenonenone
borderBottom-AutoCompletenonenone
borderBottomColor-AutoCompletenonenone
borderBottomStyle-AutoCompletenonenone
borderBottomWidth-AutoCompletenonenone
borderColor-AutoCompletenonenone
borderColor-AutoComplete--disablednonenone
borderColor-AutoComplete-defaultnonenone
borderColor-AutoComplete-default--hovernonenone
borderColor-AutoComplete-errornonenone
borderColor-AutoComplete-error--hovernonenone
borderColor-AutoComplete-successnonenone
borderColor-AutoComplete-success--hovernonenone
borderColor-AutoComplete-warningnonenone
borderColor-AutoComplete-warning--hovernonenone
borderColor-menu-AutoComplete$borderColor$borderColor
borderEndEndRadius-AutoCompletenonenone
borderEndStartRadius-AutoCompletenonenone
borderHorizontal-AutoCompletenonenone
borderHorizontalColor-AutoCompletenonenone
borderHorizontalStyle-AutoCompletenonenone
borderHorizontalWidth-AutoCompletenonenone
borderLeft-AutoCompletenonenone
color-AutoCompletenonenone
borderLeftStyle-AutoCompletenonenone
borderLeftWidth-AutoCompletenonenone
borderRadius-AutoComplete-defaultnonenone
borderRadius-AutoComplete-errornonenone
borderRadius-AutoComplete-successnonenone
borderRadius-AutoComplete-warningnonenone
borderRadius-menu-AutoComplete$borderRadius$borderRadius
borderRadius-menu-AutoComplete$borderRadius$borderRadius
borderRight-AutoCompletenonenone
color-AutoCompletenonenone
borderRightStyle-AutoCompletenonenone
borderRightWidth-AutoCompletenonenone
borderStartEndRadius-AutoCompletenonenone
borderStartStartRadius-AutoCompletenonenone
borderStyle-AutoCompletenonenone
borderStyle-AutoComplete-defaultnonenone
borderStyle-AutoComplete-errornonenone
borderStyle-AutoComplete-successnonenone
borderStyle-AutoComplete-warningnonenone
borderTop-AutoCompletenonenone
borderTopColor-AutoCompletenonenone
borderTopStyle-AutoCompletenonenone
borderTopWidth-AutoCompletenonenone
borderHorizontal-AutoCompletenonenone
borderVerticalColor-AutoCompletenonenone
borderVerticalStyle-AutoCompletenonenone
borderVerticalWidth-AutoCompletenonenone
borderWidth-AutoCompletenonenone
borderWidth-AutoComplete-defaultnonenone
borderWidth-AutoComplete-errornonenone
borderWidth-AutoComplete-successnonenone
borderWidth-AutoComplete-warningnonenone
borderWidth-menu-AutoComplete1px1px
boxShadow-AutoComplete-defaultnonenone
boxShadow-AutoComplete-default--hovernonenone
boxShadow-AutoComplete-errornonenone
boxShadow-AutoComplete-error--hovernonenone
boxShadow-AutoComplete-successnonenone
boxShadow-AutoComplete-success--hovernonenone
boxShadow-AutoComplete-warningnonenone
boxShadow-AutoComplete-warning--hovernonenone
boxShadow-menu-AutoComplete$boxShadow-md$boxShadow-md
boxShadow-menu-AutoComplete$boxShadow-md$boxShadow-md
fontSize-AutoComplete-badge$fontSize-small$fontSize-small
fontSize-AutoComplete-badge$fontSize-small$fontSize-small
fontSize-AutoComplete-defaultnonenone
fontSize-AutoComplete-errornonenone
fontSize-AutoComplete-successnonenone
fontSize-AutoComplete-warningnonenone
fontSize-placeholder-AutoComplete-defaultnonenone
fontSize-placeholder-AutoComplete-errornonenone
fontSize-placeholder-AutoComplete-successnonenone
fontSize-placeholder-AutoComplete-warningnonenone
minHeight-Input39px39px
outlineColor-AutoComplete--focusnonenone
outlineOffset-AutoComplete--focusnonenone
outlineStyle-AutoComplete--focusnonenone
outlineWidth-AutoComplete--focusnonenone
paddingHorizontal-AutoComplete-badge$space-2$space-2
paddingVertical-AutoComplete-badge$space-1$space-1
textColor-AutoComplete--disablednonenone
textColor-AutoComplete-badge$const-color-surface-50$const-color-surface-50
textColor-AutoComplete-badge$const-color-surface-50$const-color-surface-50
textColor-AutoComplete-badge--activenonenone
textColor-AutoComplete-badge--hovernonenone
textColor-AutoComplete-defaultnonenone
textColor-AutoComplete-default--hovernonenone
textColor-AutoComplete-errornonenone
textColor-AutoComplete-error--hovernonenone
textColor-AutoComplete-successnonenone
textColor-AutoComplete-success--hovernonenone
textColor-AutoComplete-warningnonenone
textColor-AutoComplete-warning--hovernonenone
textColor-item-AutoComplete--disabled$color-surface-200$color-surface-200
textColor-placeholder-AutoCompletenonenone
textColor-placeholder-AutoComplete-defaultnonenone
textColor-placeholder-AutoComplete-errornonenone
textColor-placeholder-AutoComplete-successnonenone
textColor-placeholder-AutoComplete-warningnonenone
This site is an XMLUI™ app.