Skip to content
On this page

Step 2: Add Event Handling

js
import { LitElement, html } from 'lit-element'

export class CustomAlert extends LitElement {
  // ...

  _close() {
    this.hidden = true;
  }

  render() {
    return html`
      <svg> ... </svg>
      <slot></slot>
      <button part="button" @click="${this._close}">Close</button>
    `
  }
}
import { LitElement, html } from 'lit-element'

export class CustomAlert extends LitElement {
  // ...

  _close() {
    this.hidden = true;
  }

  render() {
    return html`
      <svg> ... </svg>
      <slot></slot>
      <button part="button" @click="${this._close}">Close</button>
    `
  }
}

Licenced MIT