Symbiote.js
Get startedTemplatesPropertiesAttributesFlagsContextLifecycleList itemsStylingSSRRoutingPubSubEcosystemLive examples

Attributes

Like the all other regular DOM-elements, Symbiote-components can have their own HTML-attributes. And like the all standard Custom Element, Symbiote-components can react to dynamic attribute changes.

Attribute connection

The most simple way to connect some local state property to the actual attribute value is to use the @-token:

class MyComponent extends Symbiote {

  init$ = {
    '@attribute-name': 'initial value',
  }

}

Or you can initiate this type of property from the component's template directly:

class MyComponent extends Symbiote {}

MyComponent.template = html`<h1>{{@attribute-name}}</h1>`;

Then you can use it as an attribute in your markup:

<my-component attribute-name="attribute value"><my-component>

Reaction on attribute changes with the property accessor:

class MyComponent extends Symbiote {

  set 'my-attribute'(val) {
    console.log(val);
  }

}

MyComponent.observedAttributes = [
  'my-attribute',
];

Also, you can bind attributes to property values directly:

class MyComponent extends Symbiote {

  init$ = {
    myProp: '',
  }

}

// Map the attribute name to corresponding property key:
MyComponent.bindAttributes({
  'my-attribute': 'myProp',
});

// This will render the attribute value as a text node:
MyComponent.template = html`
  <div>{{myProp}}</div>
`;

List of the reserved attribute names

  • bind
  • ctx
  • ctx-owner
  • ref
  • itemize
  • item-tag
  • use-template
  • skip-text-nodes

Proceed to Flags

11.12.2025
JSDA is very simple
Why JSDA is the best way to build web apps
28.09.2024
It was really possible?
Symbiote.js as an answer to many questions
17.09.2024
Smart HTML-tags
Simple recipe with the Artificial Intelligence
25.01.2024
Symbiote VS Lit
David and Goliath: differences, pros and cons...
18.01.2024
Symbiote.js 2.x
The new major version is released. Let's see what's new...
RND-PRO.com © 2025