How to toggle panel header visibility using a button in the Blazor Dashboard Layout component?
To show/hide the header of a Blazor Dashboard Layout component on button click, you can manipulate the display property of the header element by adjusting the CssClass property value of the Dashboard Layout component.
<SfButton OnClick="Toggle">Toggle button</SfButton>
<div class="content"> <SfDashboardLayout Columns="6" CellSpacing="@(new double[]{10 ,10 })"> <DashboardLayoutPanels> <DashboardLayoutPanel SizeX="4" SizeY="2" CssClass="@DisplayHeader"> <HeaderTemplate> <div class='header'> Header </div> </HeaderTemplate> <ContentTemplate> Panel 1 </ContentTemplate> </DashboardLayoutPanel> </DashboardLayoutPanels> </SfDashboardLayout> </div>
@code { private string DisplayHeader = "show";
public void Toggle() { DisplayHeader = (DisplayHeader == "show") ? "hide" : "show"; } } <style> .hide .e-panel-header { display: none; } </style> |
Refer to the following link for a sample:
https://blazorplayground.syncfusion.com/hZBpNrXRTexFFXsy
Conclusion
We hope you enjoyed learning how to toggle panel header visibility using a button in the Blazor Dashboard Layout component.
You can refer to our Blazor Dashboard Layout feature tour page to learn about its other features, documentation, and how to quickly get started with configuration specifications. You can also explore our Blazor Dashboard Layout example to understand how to create and visualize data.
For current customers, our Blazor components are available on the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to evaluate our Blazor Dashboard Layout and other Blazor components.
If you have any questions or require clarifications, please let us know in the comment section below. You can also contact us through our support forums, support portal, or feedback portal. We are always happy to assist you!