Lit (library)
| Developer(s) | Google[1] and other contributors[2] |
|---|---|
| Initial release | December 13, 2018[3] [4] |
| Stable release | 2.0.2
/ October 8, 2021 |
| Repository | github |
| Written in | JavaScript |
| Engine | |
| Platform | Web platform |
| Type | JavaScript library |
| License | BSD 3-Clause[1] |
| Website | lit |
Search Lit (library) on Amazon.
Lit is an open-source JavaScript library for building web components and web applications[5]. Lit is the successor to the Polymer library [6] and is developed by Google and other contributors on GitHub.
Overview
Lit provides an HTML templating engine and a base class called LitElement. The templating engine makes use of JavaScript template literals to create and dynamically update the DOM of a webpage. The LitElement base class extends the built-in HTMLElement class, providing the ability to render Lit templates to the component's Shadow DOM, and to automatically re-render when its properties or attributes change.
Example
The following examples in TypeScript and JavaScript define a new HTML element called <simple-greeting>. This new HTML element can be used just like built-in HTML elements such as <button>, with the browser referring to the implementation defined below to determine what should be displayed. When the name property or attribute changes, the Shadow DOM within the component will be re-rendered to reflect the new value.
TypeScript
import {html, css, LitElement} from 'lit';
import {customElement, property} from 'lit/decorators.js';
@customElement('simple-greeting')
export class SimpleGreeting extends LitElement {
static styles = css`p { color: blue }`;
@property()
name = 'Somebody';
render() {
return html`<p>Hello, ${this.name}!</p>`;
}
}
JavaScript
import {html, css, LitElement} from 'lit';
export class SimpleGreeting extends LitElement {
static styles = css`p { color: blue }`;
static properties = {
name: {type: String},
};
constructor() {
super();
this.name = 'Somebody';
}
render() {
return html`<p>Hello, ${this.name}!</p>`;
}
}
customElements.define('simple-greeting', SimpleGreeting)
Adoption
Lit has been adopted by a number of companies for creating web component systems:
- Adobe Photoshop for the web[7], Spectrum Web Components [8]
- Alaska Airlines Auro Design System[9]
See also
References
- ↑ 1.0 1.1 "LICENSE". GitHub. Retrieved December 7, 2021.
- ↑ "Contributors to Lit". GitHub. Retrieved December 7, 2021.
- ↑ Gray Norton (December 13, 2018). "lit-html 1.0 release candidate". Polymer Blog. Retrieved December 7, 2021.
- ↑ Justin Fagnani (February 2019). "Lightning-fast templates & Web Components: lit-html & LitElement". Google Developers Blog. Retrieved December 7, 2021.
- ↑ "Lit". Retrieved December 7, 2021.
- ↑ "Polymer". GitHub. Retrieved December 7, 2021.
- ↑ "Photoshop's journey to the web | Web Components and Lit". Oct 26, 2021. Retrieved December 7, 2021.
- ↑ "Spectrum Web Components". Retrieved December 7, 2021.
- ↑ "Auro Design System". Retrieved December 7, 2021.
- ↑ "Momentum UI Web Components". GitHub. Retrieved December 7, 2021.
- ↑ "Material Design Web Components". GitHub. Retrieved December 7, 2021.
- ↑ "Carbon Design System". GitHub. Retrieved December 7, 2021.
- ↑ "Lion". Retrieved December 7, 2021.
- ↑ "UI5 Web Components". GitHub. Retrieved December 7, 2021.
External links
This article "Lit (library)" is from Wikipedia. The list of its authors can be seen in its historical and/or the page Edithistory:Lit (library). Articles copied from Draft Namespace on Wikipedia could be seen on the Draft Namespace of Wikipedia and not main one.
