Skip to content
navius

Collapsible

An interactive component which expands and collapses a panel.

@lzitser23 starred 3 repositories

Features

  • Full keyboard navigation.
  • Can be controlled (@bind-Open) or uncontrolled (DefaultOpen).
  • Publishes --collapsible-panel-height / -width so CSS height/width transitions work as a drop-in.
  • KeepMounted keeps the panel mounted while closed so exit animations can run.

Installation

Reference the Navius.Primitives package for the headless primitive, or vendor a styled version with the CLI: navius add copies the styled zits/ui component plus the brain files it depends on.

Anatomy

Import the parts and assemble them.

API Reference

Contains all the parts of a collapsible. Renders a div.

Prop Type Default
Open bool false
OpenChanged EventCallback<bool> -
DefaultOpen bool false
Disabled bool false
ChildContent RenderFragment? -
Data attribute Values
[data-disabled] Present when disabled

The button that toggles the collapsible. Renders a button.

Prop Type Default
ChildContent RenderFragment? -
Data attribute Values
[data-panel-open] Present while the panel is open.
[data-disabled] Present when disabled

The panel that expands and collapses. Renders a div when open (or always, with KeepMounted).

Prop Type Default
KeepMounted bool false
ChildContent RenderFragment? -
Data attribute Values
[data-open] Present while open.
[data-closed] Present while closing (through the exit transition).
[data-starting-style] Present at the start of the open transition.
[data-ending-style] Present at the start of the close transition.
[data-disabled] Present when disabled

Accessibility

Implements the roles, states, and keyboard map of the disclosure WAI-ARIA APG pattern. Covered by the browser test suite and an axe-core WCAG gate in CI.

Key Description
Space Opens/closes the collapsible.
Enter Opens/closes the collapsible.