Expansion Panels

Simple Usage

Panel One
Panel One Content
Panel Two
Panel Two Content
Panel Three
Panel Three Content
Panel Four
Panel Four Content
<MudExpansionPanels>
    <MudExpansionPanel Text="Panel One" MaxHeight="150" IsExpanded="true">
        Panel One Content
    </MudExpansionPanel>
    <MudExpansionPanel Text="Panel Two" MaxHeight="500">
        Panel Two Content
    </MudExpansionPanel>
    <MudExpansionPanel Text="Panel Three" MaxHeight="1000">
        Panel Three Content
    </MudExpansionPanel>
    <MudExpansionPanel Text="Panel Four">
        Panel Four Content
    </MudExpansionPanel>
</MudExpansionPanels>
Multiple Expanded Panels

Multiple expansion panels can be opened at the same time by setting MultiExpansion.

Panel One
Panel One Content
Panel Two
Panel Two Content
Panel Three
Panel Three Content
Panel Four
Panel Four Content
<MudExpansionPanels MultiExpansion="true">
    <MudExpansionPanel Text="Panel One">
        Panel One Content
    </MudExpansionPanel>
    <MudExpansionPanel Text="Panel Two">
        Panel Two Content
    </MudExpansionPanel>
    <MudExpansionPanel Text="Panel Three">
        Panel Three Content
    </MudExpansionPanel>
    <MudExpansionPanel Text="Panel Four">
        Panel Four Content
    </MudExpansionPanel>
</MudExpansionPanels>
Async loading of data

The panels inner collapsible won't expand until IsExpandedChanged has completed, enabling smooth opening of expansion panels even if the data is not loaded when the header is clicked.

Panel with async loaded contents
<MudExpansionPanels>
    <MudExpansionPanel Text="Panel with async loaded contents" MaxHeight="1000" IsExpandedChanged="ExpandedChanged">
        @_panelContent
    </MudExpansionPanel>
</MudExpansionPanels>
@code {
    private RenderFragment _panelContent;

    private async Task ExpandedChanged(bool newVal)
    {
        if (newVal)
        {
            await Task.Delay(600);
            _panelContent = _bigAsyncContent;
        }
        else
        {
            // Reset after a while to prevent sudden collapse.
            Task.Delay(350).ContinueWith(t => _panelContent = null).AndForget(); 
        }
    }

    private RenderFragment _bigAsyncContent = __builder =>
    {
        <div>The expansion of the</div>
        <div>inner panel is done after</div>
        <div>IsExpandedChanged</div>
        <div>has completed to allow for</div>
        <div>smooth opening of async data</div>
        <div>of initially unknown height.</div>
    };
}

Copyright © 2020-2024 MudBlazor.

Powered by .NET 8.0.8

An error has occurred. This application may no longer respond until reloaded. Reload 🗙