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

3.2.1 • 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!')
  }
}

/@joist/element/

    Package Sidebar

    Install

    npm i @joist/element

    Weekly Downloads

    176

    Version

    3.2.1

    License

    MIT

    Unpacked Size

    83.8 kB

    Total Files

    59

    Last publish

    Collaborators

    • deebloo