Loading...
Loading...
Guide for implementing the Syncfusion Blazor Accordion component for creating collapsible panels with expandable content. Use this skill when users need to build accordions, implement collapsible sections, create expandable panels, organize content in navigation components, implement FAQs, build collapsible menus, add nested accordions, configure expand modes (single or multiple), handle accordion events, customize accordion styling, implement accessible accordions with WCAG compliance, integrate data binding, or work with any vertically collapsible content containers in Blazor applications.
npx skill4agent add syncfusion/blazor-ui-components-skills syncfusion-blazor-accordion@using Syncfusion.Blazor.Navigations
<SfAccordion>
<AccordionItems>
<AccordionItem Header="ASP.NET" Content="Microsoft ASP.NET is a set of technologies for building Web applications."></AccordionItem>
<AccordionItem Header="ASP.NET MVC" Content="The Model-View-Controller pattern separates an application into three components."></AccordionItem>
<AccordionItem Header="JavaScript" Content="JavaScript is an interpreted programming language for web development."></AccordionItem>
</AccordionItems>
</SfAccordion>@using Syncfusion.Blazor.Navigations
<SfAccordion>
<AccordionItems>
<AccordionItem>
<HeaderTemplate>
<div>Employee Details</div>
</HeaderTemplate>
<ContentTemplate>
<div>
<b>Name:</b> John Doe<br />
<b>Position:</b> Software Engineer
</div>
</ContentTemplate>
</AccordionItem>
</AccordionItems>
</SfAccordion>@using Syncfusion.Blazor.Navigations
<SfAccordion>
<AccordionItems>
@foreach (var item in AccordionData)
{
<AccordionItem>
<HeaderTemplate>
<div>@item.Title</div>
</HeaderTemplate>
<ContentTemplate>
<div>@item.Content</div>
</ContentTemplate>
</AccordionItem>
}
</AccordionItems>
</SfAccordion>
@code {
List<DataItem> AccordionData = new List<DataItem>() {
new DataItem { Title = "Item 1", Content = "Content 1" },
new DataItem { Title = "Item 2", Content = "Content 2" }
};
public class DataItem {
public string Title { get; set; }
public string Content { get; set; }
}
}<SfAccordion ExpandMode="ExpandMode.Single">
<AccordionItems>
<AccordionItem Expanded="true" Header="Question 1" Content="Answer 1"></AccordionItem>
<AccordionItem Header="Question 2" Content="Answer 2"></AccordionItem>
</AccordionItems>
</SfAccordion><SfAccordion>
<AccordionEvents Expanding="OnExpanding" Expanded="OnExpanded"></AccordionEvents>
<AccordionItems>
<AccordionItem Header="Item 1" Content="Content 1"></AccordionItem>
</AccordionItems>
</SfAccordion>
@code {
public void OnExpanding(ExpandEventArgs args) {
// Perform validation or load data before expansion
}
public void OnExpanded(ExpandedEventArgs args) {
// Handle post-expansion actions
}
}<SfButton @onclick="AddItem">Add Item</SfButton>
<SfAccordion>
<AccordionItems>
@foreach (var item in Items)
{
<AccordionItem Header="@item.Header" Content="@item.Content"></AccordionItem>
}
</AccordionItems>
</SfAccordion>
@code {
List<ItemData> Items = new List<ItemData>();
void AddItem() {
Items.Add(new ItemData { Header = "New Item", Content = "New Content" });
}
}<SfAccordion>
<AccordionItems>
<AccordionItem Header="Parent Item">
<ContentTemplate>
<SfAccordion>
<AccordionItems>
<AccordionItem Header="Child Item 1" Content="Child Content 1"></AccordionItem>
<AccordionItem Header="Child Item 2" Content="Child Content 2"></AccordionItem>
</AccordionItems>
</SfAccordion>
</ContentTemplate>
</AccordionItem>
</AccordionItems>
</SfAccordion>| Property | Type | Default | Description |
|---|---|---|---|
| ExpandMode | Multiple | Controls whether single or multiple items can be expanded |
| int[] | null | Array of indices for initially expanded items |
| bool | true | Whether to load content on demand or at initial render |
| Property | Type | Default | Description |
|---|---|---|---|
| string | null | Text content for the accordion header |
| string | null | Text content for the accordion panel |
| RenderFragment | null | Custom template for the header |
| RenderFragment | null | Custom template for the content |
| bool | false | Whether the item is initially expanded |
| bool | false | Whether the item is disabled |
| bool | true | Whether the item is visible |
| string | null | CSS class for custom header icon |
| string | null | Custom CSS class for the item |
AccordionAnimationSettings<SfAccordion>
<AccordionAnimationSettings>
<AccordionAnimationExpand Effect="AnimationEffect.SlideDown" Duration="400"></AccordionAnimationExpand>
<AccordionAnimationCollapse Effect="AnimationEffect.SlideUp" Duration="400"></AccordionAnimationCollapse>
</AccordionAnimationSettings>
<AccordionItems>
<!-- Items here -->
</AccordionItems>
</SfAccordion>SlideDownSlideUpFadeInFadeOutFadeZoomInFadeZoomOutZoomInZoomOutNoneExpandMode.SingleExpanded="true"DisabledExpandedExpandingIconCssClickedLoadOnDemand="true"Multipleforeach