Buckets:
| Name | Size | Uploaded | Xet hash |
|---|---|---|---|
| decorators | 40 items | ||
| development | 60 items | ||
| node | 56 items | ||
| LICENSE | 1.52 kB xet | db19e73e | |
| README.md | 2.94 kB xet | 576752f9 | |
| css-tag.d.ts | 2.8 kB xet | c457bbb8 | |
| css-tag.d.ts.map | 908 Bytes xet | 2b124c68 | |
| css-tag.js | 1.59 kB xet | 6ed40043 | |
| css-tag.js.map | 8.8 kB xet | 7e1e92b5 | |
| decorators.d.ts | 544 Bytes xet | dce09c3f | |
| decorators.d.ts.map | 332 Bytes xet | b4eaf02f | |
| decorators.js | 544 Bytes xet | c650962b | |
| decorators.js.map | 94 Bytes xet | 5722e5cb | |
| package.json | 15.3 kB xet | e244558a | |
| polyfill-support.d.ts | 631 Bytes xet | 0c59df98 | |
| polyfill-support.d.ts.map | 177 Bytes xet | e7f9d78b | |
| polyfill-support.js | 1.54 kB xet | b2751c81 | |
| polyfill-support.js.map | 7.26 kB xet | f529bba7 | |
| reactive-controller.d.ts | 2.95 kB xet | fd0b3fde | |
| reactive-controller.d.ts.map | 640 Bytes xet | de0bd785 | |
| reactive-controller.js | 49 Bytes xet | a4d3d2fc | |
| reactive-controller.js.map | 103 Bytes xet | 63c5dbef | |
| reactive-element.d.ts | 30.9 kB xet | fc60f86d | |
| reactive-element.d.ts.map | 6.08 kB xet | 6c899709 | |
| reactive-element.js | 6.31 kB xet | 07edd3e2 | |
| reactive-element.js.map | 73.2 kB xet | b461813f |
ReactiveElement
A simple low level base class for creating fast, lightweight web components.
Documentation
Full documentation is available at lit.dev/docs/api/ReactiveElement/.
Overview
ReactiveElement is a base class for writing web components that react to changes in properties and attributes. ReactiveElement adds reactive properties and a batching, asynchronous update lifecycle to the standard web component APIs. Subclasses can respond to changes and update the DOM to reflect the element state.
ReactiveElement doesn't include a DOM template system, but can easily be extended to add one by overriding the update() method to call the template library. LitElement is such an extension that adds lit-html templating.
Example
import {
ReactiveElement,
html,
css,
customElement,
property,
PropertyValues,
} from '@lit/reactive-element';
// This decorator defines the element.
@customElement('my-element')
export class MyElement extends ReactiveElement {
// This decorator creates a property accessor that triggers rendering and
// an observed attribute.
@property()
mood = 'great';
static styles = css`
span {
color: green;
}
`;
contentEl?: HTMLSpanElement;
// One time setup of shadowRoot content.
createRenderRoot() {
const shadowRoot = super.createRenderRoot();
shadowRoot.innerHTML = `Web Components are <span></span>!`;
this.contentEl = shadowRoot.firstElementChild;
return shadowRoot;
}
// Use a DOM rendering library of your choice or manually update the DOM.
update(changedProperties: PropertyValues) {
super.update(changedProperties);
this.contentEl.textContent = this.mood;
}
}
<my-element mood="awesome"></my-element>
Note, this example uses decorators to create properties. Decorators are a proposed standard currently available in TypeScript or Babel. ReactiveElement also supports a vanilla JavaScript method of declaring reactive properties.
Installation
$ npm install @lit/reactive-element
Or use from lit:
$ npm install lit
Contributing
Please see CONTRIBUTING.md.
- Total size
- 149 MB
- Files
- 6,599
- Last updated
- Jun 23
- Pre-warmed CDN
- US EU US EU