Skip to main content
Version: v7

Autofocus

Developers that want to set focus to an element on "page load" can use the setFocus API to set focus to an element. This API should be used in place of the autofocus attribute and called within the ionViewDidEnter lifecycle event.

The example below highlights the difference in behavior between the autofocus attribute and the setFocus API.

danger

Developers will receive a warning in their console when using the autofocus attribute in the StackBlitz examples due to cross-origin restrictions.