Simple Usage
<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
.
<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.
<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> }; }