@collapsed/lit
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

@collapsed/lit

NPM Version npm bundle size

A Lit element for creating accessible expand/collapse elements. Animates the height using CSS transitions from 0 to auto.

Features

  • Handles the height of animations of your elements, auto included!
  • Minimally-styled to be functional--you control the styles.
  • No animation framework required! Simply powered by CSS animations.

Installation

npm install @collapsed/lit

Usage

import { CollapsedDisclosure } from "@collapsed/lit";
import { html } from "lit";

export function App() {
  function handleClick(evt) {
    const collapse = document.querySelector("#disclosure");
    const btn = event.target;
    collapse.toggleAttribute("open");
    btn.setAttribute("aria-expanded", collapse.hasAttribute("open").toString());
  }

  return html`<div>
    <button
      aria-controls="disclosure"
      aria-expanded="false"
      @click="${handleClick}"
    >
      Toggle
    </button>
    <collapsed-disclosure id="disclosure">
      <!-- Content goes here -->
    </collapsed-disclosure>
  </div>`;
}

Readme

Keywords

none

Package Sidebar

Install

npm i @collapsed/lit

Weekly Downloads

0

Version

0.0.1

License

MIT

Unpacked Size

17.3 kB

Total Files

9

Last publish

Collaborators

  • roginfarrer