@joist/element
TypeScript icon, indicating that this package has built-in type declarations

3.1.2 • Public • Published

Element

Create a shadow root and apply styles and html as defined

Installation:

npm i @joist/element

Example:

import { tagName, shadow, css, html, attr, listen, element } from '@joist/element';

@element
export class MyElement extends HTMLElement {
  // define a custom element
  @tagName static tagName = 'my-element';

  // apply styles to shadow dom
  @shadow styles = css`
    :host {
      display: block;
      color: red;
    }
  `;

  // apply html to shadow dom
  @shadow template = html`
    <slot></slot>
  `;

  // define attributes
  @attr accessor value = 0;

  // listen for events
  @listen('click') onClick() {
    console.log('clicked!')
  }
}

Package Sidebar

Install

npm i @joist/element

Weekly Downloads

5

Version

3.1.2

License

MIT

Unpacked Size

84.5 kB

Total Files

59

Last publish

Collaborators

  • deebloo