Skip to content
LAYOUT · FREE

Collapse

Show details only when users ask for them.

Show or hide content on demand. Bind it to any button and keep the content in the page while hidden if you need it.

Why it helps

  • Works with any button
  • Keep content mounted
  • Simple

Where it fits

  • Advanced options
  • Details
  • Filters
Collapse control in a RayCraft page

Example

<Button Variant="Variant.Outlined" OnClick="@(() => _open = !_open)" aria-expanded="@(_open ? "true" : "false")" aria-controls="@(_open ? "collapse-demo" : null)">
    @(_open ? "Hide details" : "Show details")
</Button>
<Collapse Expanded="_open" id="collapse-demo">
    <Card>Details that appear and disappear. The content is not rendered while collapsed.</Card>
</Collapse>

@code {
    private bool _open;
}

A short fragment. Add @using RayCraft.Blazor.Components to your page and use an interactive render mode.

Included in RayCraft Free. Working examples are in the GitHub repository (MIT); it holds example and demo code, not the library code.

All controls ยท Documentation