Skip to content
loseta

Components / Disclosure

Collapsible

A native disclosure that reveals or hides content.

Status stable
Show details

This content is revealed with the native details element.

<details class="collapsible">
  <summary>
    Show details
    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m6 9 6 6 6-6"/></svg>
  </summary>
  <div>
    <p>This content is revealed with the native details element.</p>
  </div>
</details>

Installation

pnpm dlx loseta add collapsible
npx loseta add collapsible

Examples

Open

Shipping information

Orders placed before 14:00 ship the same day.

Tracking details arrive by email.

<details class="collapsible" open>
  <summary>
    Shipping information
    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m6 9 6 6 6-6"/></svg>
  </summary>
  <div>
    <p>Orders placed before 14:00 ship the same day.</p>
    <p>Tracking details arrive by email.</p>
  </div>
</details>

Accessibility and behavior

  • Native <details> with <summary> as the trigger and content directly after it. Use [open] and inert; no JavaScript is required. For exclusive groups, use several details with the same name.

Files

components/collapsible.cssbase
styles/nova/collapsible.cssstyle

Install contract

The CLI writes the base file under components/, the visual file for the selected style under styles/<name>/, and any primitive dependency underprimitives/. The generated index.css imports them in the right layer order.

← Back to components

loseta is MIT licensed. Built with native CSS, no runtime. Inspired byshadcn/ui.