All HTML attributes are reactive by default. When an attribute’s value changes in the component HTML, the component is rerendered.
To enable a screen reader to read a value aloud to the user, use
@api to expose a public
When you take control of an attribute by exposing it as a public property, the attribute doesn't appear in the HTML output by default.
To pass the value through to the rendered HTML as an attribute (to reflect the property), define a getter and setter for the property and call the
You can also perform operations in the setter. Use a field to hold the computed value.
This example exposes
title as a public property. It converts the title to uppercase and uses the property
_privateTitle to hold the computed value of the title. The setter calls
setAttribute() to reflect the property’s value to the HTML attribute.
setAttribute(). The generated HTML doesn’t include the
Before you set a value, check if the value has already been set by the consumer.
this.setAttribute() results in this markup.
To set and get these attributes, use
To hide HTML attributes from the rendered HTML, call