Lit is a simple library for building fast, lightweight web components.
At Lit's core is a boilerplate-killing component base class that provides reactive state, scoped styles, and a declarative template system that's tiny, fast and expressive.
Lit 3.0 has very few breaking changes from Lit 2.0:
Lit 3.0 should require no changes to upgrade from Lit 2.0 for the vast majority of users. Most apps and libraries will be able to extend their npm version ranges to include both 2.x and 3.x, like "^2.7.0 || ^3.0.0"
.
Lit 2.x and 3.0 are interoperable: templates, base classes, directives, decorators, etc., from one version of Lit will work with those from another.
Please file any issues you find on our issue tracker.
See the full documentation for Lit at lit.dev
Lit provides developers with just the right tools to build fast web components:
Lit builds on top of standard web components, and makes them easier to write:
import {LitElement, html, css} from 'lit';
import {customElement, property} from 'lit/decorators.js';
// Registers the element
@customElement('my-element')
export class MyElement extends LitElement {
// Styles are applied to the shadow root and scoped to this element
static styles = css`
span {
color: green;
}
`;
// Creates a reactive property that triggers rendering
@property()
mood = 'great';
// Render the component's DOM by returning a Lit template
render() {
return html`Web Components are <span>${this.mood}</span>!`;
}
}
Once you've defined your component, you can use it anywhere you use HTML:
<my-element mood="awesome"></my-element>
Please see CONTRIBUTING.md.