id

Optional

Type: string

Default: unset

An id can be assigned to a UI component, which then targets the specific component and enables calling component methods on it from JavaScript/TypeScript.

Example - id on a text-input

main.view.xml
<var name="first_name" type="text"/>

<text-input id="first-name-input" label="First name" bind="first_name" />
main.js
function focusInput() {
    // call a component method to programatically focus the text-input
    component.textInput({id: 'first-name-input'}).focus();
}

Last updated