MCPcopy Index your code
hub / github.com/lit/lit-element

github.com/lit/lit-element @v2.4.0 sqlite

repository ↗ · DeepWiki ↗ · release v2.4.0 ↗
758 symbols 1,341 edges 158 files 50 documented · 7% 7 cross-repo links
README

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

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.

Extension points exported contracts — how you extend this code

InternalPropertyDeclaration (Interface)
(no doc) [2 implementers]
src/lib/decorators.ts
ShadyCSS (Interface)
(no doc)
src/env.d.ts
Window (Interface)
(no doc)
src/lit-element.ts
MyPropertyDeclaration (Interface)
(no doc)
src/test/lib/updating-element_test.ts
PropertyDeclaration (Interface)
(no doc) [2 implementers]
src/lib/updating-element.ts
ShadyDOM (Interface)
(no doc)
src/env.d.ts
CSSResultArray (Interface)
(no doc)
src/lit-element.ts
MyPropertyDeclarations (Interface)
(no doc)
src/test/lib/updating-element_test.ts

Core symbols most depended-on inside this repo

generateElementName
called by 111
src/test/test-helpers.ts
replace
called by 59
src/env.d.ts
property
called by 55
src/lib/decorators.ts
css
called by 55
src/lib/css-tag.ts
get
called by 53
docs/main.py
k
called by 43
docs/api/assets/js/main.js
m
called by 42
docs/api/assets/js/main.js
set
called by 41
src/test/lib/updating-element_test.ts

Shape

Method 322
Class 220
Function 199
Interface 17

Languages

TypeScript100%
Python1%

Modules by API surface

docs/api/assets/js/main.js119 symbols
src/test/lib/updating-element_test.ts52 symbols
src/lib/updating-element.ts47 symbols
src/test/lib/decorators_test.ts23 symbols
src/lib/decorators.ts23 symbols
src/test/lit-element_test.ts22 symbols
src/test/lit-element_styling_test.ts22 symbols
src/lit-element.ts13 symbols
docs/_includes/projects/properties/attributeconverter/my-element.js11 symbols
src/env.d.ts9 symbols
docs/_includes/projects/properties/defaultconverter/my-element.js9 symbols
src/lib/css-tag.ts8 symbols

Dependencies from manifests, versioned

@babel/cli7.2.3 · 1×
@babel/core7.9.0 · 1×
@babel/plugin-proposal-class-properties7.2.3 · 1×
@babel/plugin-proposal-decorators7.2.3 · 1×
@babel/plugin-transform-typescript7.2.0 · 1×
@babel/preset-env7.9.5 · 1×
@rollup/plugin-node-resolve7.1.3 · 1×
@stackblitz/sdk1.3.0 · 1×
@types/chai4.0.1 · 1×
@types/mocha5.2.4 · 1×
@webcomponents/shadycss1.8.0 · 1×
@webcomponents/webcomponentsjs2.2.3 · 1×

For agents

$ claude mcp add lit-element \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact