JSX attributes

attr:*

Edit this page

attr:* 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 the name attribute after the attr: prefix is removed.
  • In the DOM runtime, attr:name={undefined} or attr: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} />

Report an issue with this page