mcpField
S
syncfusion-blazor-accordion

syncfusion-blazor-accordion

github.com/syncfusionDesign & UI4351 installsUpdated 1w ago
Repository

About syncfusion-blazor-accordion

A usage skill for Syncfusion’s Blazor Accordion component, aimed at developers building collapsible interfaces. It covers expansion behavior, data binding, templates, styling, accessibility, and animation configuration.

Key features

  1. 01Single or multiple panel expansion
  2. 02Nested panels and templates
  3. 03Data binding and expansion events
  4. 04On-demand content loading
  5. 05Animation, styling, and accessibility settings

Use cases

  1. 01Creating collapsible FAQ sections
  2. 02Building nested navigation menus
  3. 03Implementing validated step-by-step wizards
  4. 04Displaying structured data compactly

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/syncfusion/blazor-ui-components-skills --skill syncfusion-blazor-accordion

After installing, type/syncfusion-blazor-accordionin Claude Code to confirm it loaded.

Bundled files

References and scripts installed along with SKILL.md.

references/
accessibility-animations.md
content-rendering.md
customization-styling.md
data-binding-events.md
expand-modes.md
getting-started.md
how-to-scenarios.md

Details

From the project README

Syncfusion Blazor Accordion Component

The Blazor Accordion is a vertically collapsible content container that displays one or more panels. Each panel consists of a header and expandable content section. It supports single or multiple panel expansion, nested accordions, animations, and is fully accessible with WCAG compliance.

When to Use This Skill

Use this skill when you need to:

  • Create collapsible content sections in Blazor applications
  • Build FAQ sections with expandable answers
  • Implement navigation menus with nested items
  • Organize large amounts of content in compact, expandable panels
  • Create wizard-like interfaces with sequential steps
  • Display hierarchical data with nested accordions
  • Implement accessible collapsible components with keyboard navigation
  • Configure expand/collapse animations and behavior
  • Bind dynamic data to accordion items
  • Customize accordion appearance and styling

Documentation and Navigation Guide

Getting Started

📄 Read: references/getting-started.md

  • Installing Syncfusion.Blazor.Navigations NuGet package
  • Namespace imports and service registration
  • Adding theme and script references
  • Creating your first accordion with basic items
  • Implementing accordions using templates (HeaderTemplate, ContentTemplate)
Expand Modes and Behavior

📄 Read: references/expand-modes.md

  • Single expand mode (only one panel open at a time)
  • Multiple expand mode (multiple panels can be open)
  • Configuring initial expanded state with ExpandedIndices
  • Setting individual item expansion with Expanded property
  • Controlling default expand behavior
Content Rendering

📄 Read: references/content-rendering.md

  • LoadOnDemand property for performance optimization
  • Rendering all content at initial load
  • On-demand content loading (default behavior)
  • Performance considerations for large accordions
Data Binding and Events

📄 Read: references/data-binding-events.md

  • Binding local data with foreach loops
  • Using HeaderTemplate and ContentTemplate for dynamic content
  • Handling Created and Destroyed lifecycle events
  • Responding to Clicked events
  • Managing Expanding/Expanded and Collapsing/Collapsed events
  • Preventing default expand/collapse behavior with event args
Customization and Styling

📄 Read: references/customization-styling.md

  • Customizing accordion border and appearance
  • Styling accordion items with CSS
  • Customizing header content and expand/collapse icons
  • Applying hover and selected item styles
  • Using CssClass property on individual items
  • CSS class structure and available classes
  • Theme integration and responsive design
Accessibility and Animations

📄 Read: references/accessibility-animations.md

  • WCAG 2.2 and Section 508 compliance
  • ARIA attributes and screen reader support
  • Keyboard navigation (Arrow keys, Space/Enter, Home/End)
  • RTL support and color contrast
  • Configuring expand/collapse animations
  • Animation effects (SlideDown, SlideUp, FadeIn, FadeOut, ZoomIn, ZoomOut, None)
  • Customizing animation duration and easing
How-To Scenarios

📄 Read: references/how-to-scenarios.md

  • Adding custom icons to accordion headers
  • Creating nested accordions (accordion within accordion)
  • Dynamically adding and removing accordion items
  • Creating wizard interfaces with sequential validation
  • Enabling or disabling specific accordion items
  • Integrating other components (TreeView, etc.) inside accordion content
  • Preventing expand/collapse for specific conditions
  • Showing or hiding accordion items conditionally

Quick Start

Basic 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>
Accordion with Templates
@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>
Data-Bound Accordion
@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; }
    }
}

Common Patterns

Single Expand Mode

Use when only one panel should be open at a time (like FAQs):

<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>
Handling Expand Events

Use when you need to perform actions during expand/collapse:

<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
    }
}
Dynamic Item Management

Use when items need to be added or removed at runtime:

<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" });
    }
}
Nested Accordion

Use when you need hierarchical collapsible sections:

<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>

Key Properties and Configuration

Core Properties
PropertyTypeDefaultDescription
ExpandModeExpandModeMultipleControls whether single or multiple items can be expanded
ExpandedIndicesint[]nullArray of indices for initially expanded items
LoadOnDemandbooltrueWhether to load content on demand or at initial render
AccordionItem Properties
PropertyTypeDefaultDescription
HeaderstringnullText content for the accordion header
ContentstringnullText content for the accordion panel
HeaderTemplateRenderFragmentnullCustom template for the header
ContentTemplateRenderFragmentnullCustom template for the content
ExpandedboolfalseWhether the item is initially expanded
DisabledboolfalseWhether the item is disabled
VisiblebooltrueWhether the item is visible
IconCssstringnullCSS class for custom header icon
CssClassstringnullCustom CSS class for the item
Animation Properties

Configure expand/collapse animations using AccordionAnimationSettings:

<SfAccordion>
    <AccordionAnimationSettings>
        <AccordionAnimationExpand Effect="AnimationEffect.SlideDown" Duration="400"></AccordionAnimationExpand>
        <AccordionAnimationCollapse Effect="AnimationEffect.SlideUp" Duration="400"></AccordionAnimationCollapse>
    </AccordionAnimationSettings>
    <AccordionItems>
        <!-- Items here -->
    </AccordionItems>
</SfAccordion>

Available animation effects: SlideDown, SlideUp, FadeIn, FadeOut, FadeZoomIn, FadeZoomOut, ZoomIn, ZoomOut, None

Common Use Cases

FAQ Section

Perfect for FAQs where only one answer should be visible at a time:

  • Use ExpandMode.Single
  • Set first item as Expanded="true"
  • Style headers to look like questions
Multi-Step Form/Wizard

Create guided workflows with sequential steps:

  • Use Disabled property to prevent skipping steps
  • Use Expanded property to control which step is active
  • Handle Expanding event to validate before moving to next step
Navigation Menu

Organize navigation items hierarchically:

  • Use nested accordions for sub-menus
  • Use IconCss for menu icons
  • Handle Clicked event for navigation actions
Content Organization

Organize large amounts of content in compact form:

  • Use LoadOnDemand="true" for performance
  • Use Multiple expand mode for flexible viewing
  • Provide clear, descriptive headers
Data Display

Display structured data in collapsible sections:

  • Use data binding with foreach
  • Use templates for rich content display
  • Handle events for lazy-loading detailed data

Next Steps

Comments

Markdown supported