Close
Angular React Web Components Blazor Blazor
Open Source

Blazor Expansion Panel Overview

The Ignite UI for Blazor Expansion Panel is a lightweight accordion component which can be rendered in two states - collapsed or expanded. The expansion panel can be toggled using mouse click, or keyboard interactions.

Blazor Expansion Panel Example

Usage

The simplest way to start using the IgbExpansionPanel is as follows:

Binding to events

The Expansion Panel component raises the following events:

  • Closed - Raised when the expansion panel is collapsed
  • Opened - Raised when the expansion panel is expanded
  • Closing - Raised when the expansion panel starts collapsing
  • Opening - Raised when the expansion panel starts expanding

The following sample demonstrates how we can add some logic to our component to make it show/hide the subtitle depending on the current state of the panel.

We can do this by binding to the Opened and Closed events:

Component Customization

The IgbExpansionPanel control allows all sorts of content to be added inside of its body. It can render input, charts and even other expansion panels!

The IgbExpansionPanel allows for easy customization of the header through the exposed title, subTitle and indicator slots.

Configuring the position of the expansion indicator can be done through the IndicatorPosition property of the Expansion Panel. The possible options are start, end or none.

The next code sample demonstrates how to configure the component’s button to go on the right side.

When slotting content into the title and subtitle slots, we recommend using <span> elements rather than heading elements (<h1><h6>). Heading elements carry built-in styling (such as font size, line height, and margins) that can interfere with the component’s intended typography and layout. Using a <span> gives you a neutral container that inherits the component’s styles cleanly.

The indicator slot is intended for icon-like content. We recommend using the <igc-icon> component for this purpose. Alternatively, if you don’t want to use an icon for the indicator, a <span> element can be used to display text, symbols, or emojis.

<IgbExpansionPanel>
  <span slot="title">Golden Retriever</span>
  <span slot="subtitle">Medium-large gun dog</span>
  <IgbIcon slot="indicator" IconName="arrow_forward" Collection="material"></IgbIcon>
</IgbExpansionPanel>

Keyboard Navigation

The Ignite UI for Blazor Expansion Panel keyboard navigation is compliant with W3C accessibility standards and convenient to use.

Key Combinations

  • ALT + - expands the focused panel
  • ALT + - collapses the focused panel
  • SPACE/ENTER - toggle the expansion state of the focused panel

Styling

The IgbExpansionPanel component exposes several CSS parts, giving you full control over its style:

NameDescription
headerThe container of the expansion indicator, title and subtitle.
titleThe title container.
subtitleThe subtitle container.
indicatorThe indicator container.
contentThe expansion panel’s content wrapper.
igc-expansion-panel {
  background-color: var(--ig-secondary-900);
  color: var(--ig-secondary-900-contrast);
}

igc-button::part(base) {
  color: var(--ig-secondary-900-contrast);
}

igc-button::part(base)::before {
  background-color: var(--ig-warn-500);
}

igc-expansion-panel::part(indicator) {
  color: var(--ig-warn-500);
}

igc-expansion-panel::part(header) {
  background-color: var(--ig-secondary-900);
}

igc-expansion-panel::part(title),
igc-expansion-panel::part(subtitle) {
  color: var(--ig-warn-500);
}

API References

Additional Resources