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

Install the brain, or copy just this primitive in with the CLI.

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

Adheres to the disclosure WAI-ARIA design pattern.

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