lit-element

A simple base class for creating fast, lightweight web components

BSD-3-Clause 87 个版本
安装
npm install lit-element
yarn add lit-element
pnpm add lit-element
bun add lit-element
README

LitElement

A simple base class for creating fast, lightweight web components.

Build Status Published on npm Join our Discord Mentioned in Awesome Lit

LitElement is the base class that powers the Lit library for building fast web components.

Most users should import LitElement from the lit package rather than installing and importing from the lit-element package directly.

Documentation

Full documentation is available at lit.dev/docs/components/overview/.

Overview

LitElement is a base class for custom elements that extends the Lit project's core ReactiveElement (from `@lit/reactive-element') base class with lit-html templating. ReactiveElement enhances HTMLElement with reactive properties, additional lifecycle callbacks, convenient inline CSS authoring, and a set of useful class decorators, while lit-html provides fast, declarative HTML templating.

Example

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>!`;
  }
}

Contributing

Please see CONTRIBUTING.md.

版本列表
4.2.2 2025-12-23
4.2.1 2025-07-11
4.2.0 2025-04-11
4.1.1 2024-10-07
4.1.0 2024-08-05
4.0.6 2024-06-04
4.0.5 2024-04-15
4.0.4 2024-01-31
4.0.3 2024-01-09
4.0.2 2023-11-16
4.0.1 2023-10-28
4.0.0 2023-10-10
4.0.0-pre.1 2023-09-29
4.0.0-pre.0 2023-04-27
3.3.3 2023-08-02
3.3.2 2023-04-26
3.3.1 2023-04-03
3.3.0 2023-03-22
3.2.3-next.1 2022-07-25
3.2.3-next.0 2022-07-25
3.2.2 2022-07-22
3.2.1 2022-06-29
3.2.0 2022-02-18
3.1.2 2022-01-25
3.1.1 2022-01-06
3.1.0 2022-01-05
3.0.2 2021-11-09
3.0.1 2021-10-07
3.0.0-rc.4 2021-09-03
3.0.0-rc.3 2021-08-19
3.0.0-rc.2 2021-05-07
3.0.0-rc.1 2021-04-21
3.0.0 2021-09-21
3.0.0-pre.4 2021-03-31
3.0.0-pre.3 2021-02-12
3.0.0-pre.2 2020-12-17
3.0.0-pre.1 2020-09-22
2.5.1 2021-05-06
2.5.0 2021-04-30
2.4.0 2020-08-19
2.4.0-pre.3 2020-08-14
2.4.0-pre.2 2020-08-14
2.4.0-pre.1 2020-08-13
2.3.1 2020-03-20
2.3.0 2020-03-18
2.3.0-pre.1 2020-03-17
2.2.1 2019-07-24
2.2.0 2019-06-11
2.1.0 2019-03-21
2.0.1 2019-02-05
2.0.0-rc.5 2019-01-25
2.0.0-rc.4 2019-01-24
2.0.0-rc.3 2019-01-18
2.0.0-rc.2 2019-01-11
2.0.0-rc.1 2019-01-11
2.0.0 2019-02-05
2.0.0-dev.2283329 2019-02-05
2.0.0-dev.ff4fefd 2019-01-11
2.0.0-dev.e620444 2019-01-24
2.0.0-dev.daf5276 2019-02-05
2.0.0-dev.aa290cf 2019-01-23
2.0.0-dev.486b2a4 2019-02-05
2.0.0-dev.2cbe3e0 2019-01-25
1.0.0 2017-09-07
0.5.0 2018-07-28
0.4.13 2018-07-28
0.4.12 2018-05-04
0.4.11 2018-05-02
0.4.10 2018-04-29
0.4.9 2018-04-26
0.4.8 2018-04-20
0.4.7 2018-04-13
0.4.6 2018-04-13
0.4.5 2018-02-12
0.4.4 2018-01-11
0.4.3 2018-01-11
0.4.2 2018-01-11
0.4.1 2018-01-11
0.4.0 2018-01-11
0.2.5 2017-10-11
0.2.4 2017-10-08
0.2.3 2017-09-08
0.2.2 2017-09-08
0.2.1 2017-09-08
0.2.0 2017-09-08
0.1.0 2017-09-08