Skip to main content

Accordion Item

shadow

wje-accordion-item is the actual interactive section inside wje-accordion. It handles headline clicks, state switching, ARIA wiring between the headline and content panel, the fallback toggle icon, and the open or close events.

Basic usage inside a group

The example below uses a single item inside wje-accordion so it is clear where the headline, description, and content slots belong. The headline can contain more than plain text, including supporting or action components.

Things To Keep In Mind

  • The headline slot becomes the clickable header. After rendering, the component assigns role="button", tabindex="0", aria-controls, and aria-expanded.
  • The description slot adds supporting text in the header and content holds the expandable panel body.
  • The toggle slot is optional. If you do not provide one, the component renders a fallback wje-icon chevron.
  • wje-accordion-item:open and wje-accordion-item:close bubble to the parent wje-accordion.
  • Programmatic open and close behavior is exposed through expand() and collapse().
  • Color variants are applied through the color attribute, while detailed styling is handled through shadow parts and CSS custom properties.

Accessibility

  • The headline is keyboard-operable with Enter and Space.
  • The content panel uses role="region" and is linked back to the headline through aria-labelledby.
  • If you embed multiple interactive controls in the headline, verify that their behavior does not conflict with clicking the whole header.

Best Practices

  • Keep the headline slot focused on a clear section title rather than a long paragraph.
  • Keep description concise; longer explanatory content belongs in content.
  • If you replace the default toggle via the toggle slot, preserve a clear affordance that the item expands and collapses.
  • When opening or closing items programmatically, keep the parent wje-accordion state in mind.

Attributes and Properties

color

DescriptionApplies a contextual color variant such as primary, success, danger, warning, info, or complete.
Attributecolor
Typestring
Default-

Events

NameDescription
wje-accordion-item:openDispatched when the item is expanded.
wje-accordion-item:closeDispatched when the item is collapsed.

Methods

collapse

DescriptionCollapses the accordion item and updates the headline ARIA state.
Signature() => void

expand

DescriptionExpands the accordion item and updates the headline ARIA state.
Signature() => void

CSS Shadow Parts

NameDescription
nativeThe wrapper of the whole accordion item.
headlineThe clickable headline area.
descriptionThe description slot container inside the headline.
toggleThe toggle slot container and fallback chevron area.
contentThe expandable content panel.

CSS Custom Properties

NameDescription
--wje-accordion-backgroundBackground color of the collapsed item wrapper.
--wje-accordion-borderBorder color of the collapsed item wrapper.
--wje-accordion-border-radiusBorder radius of the item wrapper.
--wje-accordion-background-hoverBackground color used when the headline is hovered.
--wje-accordion-border-hoverBorder color used when the headline is hovered.
--wje-accordion-background-expandedBackground color of the expanded item wrapper.
--wje-accordion-border-expandedBorder color of the expanded item wrapper.
--wje-accordion-headline-colorText color of the headline area.
--wje-accordion-content-colorText color of the expandable content area.
--wje-accordion-marker-rotateRotation applied to the toggle marker icon.

Slots

NameDescription
headlineSlot for the clickable accordion headline content.
descriptionSlot for supporting text shown below the headline.
toggleSlot for a custom toggle icon or toggle content.
contentSlot for the expandable panel body.