Skip to content
A simple base class for creating fast, lightweight web components
TypeScript HTML Shell JavaScript
Branch: master
Clone or download

Latest commit

Latest commit 615745c May 20, 2020

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github Update issue templates May 1, 2020
demo Adds `static get styles()` Dec 22, 2018
docs Merge pull request #994 from FelixSchuSi/master May 12, 2020
src Format May 20, 2020
test Support new decorators proposal as implemented in Babel 7 (#422) Jan 10, 2019
.babelrc Support new decorators proposal as implemented in Babel 7 (#422) Jan 10, 2019
.clang-format Add version global (#536) Feb 5, 2019
.gitignore Use downlevel-dts, test compile in TS 3.4 (#936) Mar 19, 2020
.npmignore Use downlevel-dts, test compile in TS 3.4 (#936) Mar 19, 2020
.travis.yml update .travis.yml (#876) Jan 16, 2020
CHANGELOG.md Changes _requestUpdate to `protected requestUpdateInternal` May 1, 2020
CONTRIBUTING.md [CONTRIBUTING.md] Fix issues link. Jan 22, 2020
LICENSE Add explicit LICENSE file Jun 1, 2018
README.md Add the Slack badge to README for discoverability Oct 11, 2019
check-version-tracker.js Add prepublish check that version tracker string is current. Jun 11, 2019
package-lock.json Use Typedoc beta. Mar 21, 2020
package.json Add build:watch and quicktest npm scripts May 20, 2020
rollup.config.js Update to Rollup v1 (#785) Dec 3, 2019
travis-bench.sh Add tachometer integration to lit-element Travis Jun 10, 2019
tsconfig.json Remove almost all uses of `any`. (#457) Feb 5, 2019
tsconfig_apidoc.json Update API doc script. Dec 13, 2018
tslint.json Remove ugly type assertions for `this` (#674) May 13, 2019
typedoc.json Minor API doc improvements. Apr 27, 2020
wct.conf.json Extract WCT configuration to wct.conf.json Jun 10, 2018

README.md

LitElement

A simple base class for creating fast, lightweight web components with lit-html.

Build Status Published on npm Join our Slack Published on webcomponents.org Mentioned in Awesome lit-html BrowserStack Status

Documentation

Full documentation is available at lit-element.polymer-project.org.

Overview

LitElement uses lit-html to render into the element's Shadow DOM and adds API to help manage element properties and attributes. LitElement reacts to changes in properties and renders declaratively using lit-html. See the lit-html guide for additional information on how to create templates for lit-element.

    import {LitElement, html, css, customElement, property} from 'lit-element';

    // This decorator defines the element.
    @customElement('my-element')
    export class MyElement extends LitElement {

      // This decorator creates a property accessor that triggers rendering and
      // an observed attribute.
      @property()
      mood = 'great';

      static styles = css`
        span {
          color: green;
        }`;

      // Render element DOM by returning a `lit-html` template.
      render() {
        return html`Web Components are <span>${this.mood}</span>!`;
      }

    }
    <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. LitElement also supports a vanilla JavaScript method of declaring reactive properties.

Examples

Installation

From inside your project folder, run:

$ npm install lit-element

To install the web components polyfills needed for older browsers:

$ npm i -D @webcomponents/webcomponentsjs

Supported Browsers

The last 2 versions of all modern browsers are supported, including Chrome, Safari, Opera, Firefox, Edge. In addition, Internet Explorer 11 is also supported.

Edge and Internet Explorer 11 require the web components polyfills.

Contributing

Please see CONTRIBUTING.md.

You can’t perform that action at this time.