attr:*
Edit this pageattr:* forces a JSX key to be written as an attribute instead of a property.
Strong-Typing Custom Attributes
Type definitions are required when using TypeScript. See theTypeScript page for examples.
Syntax
<my-element attr:status={value} />Value
- Type: attribute value
Value passed to normal attribute serialization after the attr: prefix is removed.
Behavior
attr:name={value}writes the value to thenameattribute after theattr:prefix is removed.- In the DOM runtime,
attr:name={undefined}orattr:name={null}removes the attribute. - In SSR output, the stripped attribute name and escaped value are written as HTML.
Examples
Basic usage
<my-element attr:status={props.status} />