<cs-accordion-item>
ExperimentalLayoutSince 0.1

Accordion items are used inside <cs-accordion> to create expandable sections with accessible headers.

This component must be used as a child of <cs-accordion>. Please see the Accordion docs to see examples of this component in action.

The first section. Shipping & returns Orders ship within two business days. Returns are free within 30 days. The third section.

API

Importing

If you're using the autoloader or a hosted project, components load on demand — no manual import needed. To cherry-pick this component, use one of the following snippets.

npm Self-Hosted React
import '@cruglobal/cornerstone-components/components/accordion-item/accordion-item.js';
import './cornerstone/components/accordion-item/accordion-item.js';
import CsAccordionItem from '@cruglobal/cornerstone-components/react/accordion-item/index.js';

Slots

Learn more about using slots.

NameDescription
(default)The accordion item's body content.
iconOptional expand/collapse icon. Works best with <cs-icon>.
labelThe accordion item's label. Alternatively, use the label attribute.

Attributes & Properties

Learn more about attributes and properties.

PropertyAttributeDescriptionTypeDefaultReflects
disableddisabledDisables the accordion item so it can't be toggled.booleanfalseYes
expandedexpandedExpands the accordion item.booleanfalseYes
labellabelThe text label shown in the header. If you need HTML, use the label slot instead.string''

Methods

Learn more about methods.

NameDescriptionArguments
collapse()Collapses the accordion item with animation.
expand()Expands the accordion item with animation.
focus()Focuses the accordion item's trigger button.options: FocusOptions
handleExpandedChange()Animates the body open or closed, then announces that the transition settled. The generation guard returns before dispatching on purpose: a superseded transition must not emit a completion event, or a consumer sees a collapse that never happened. rapid toggling > should only fire the final after event when the animation is interrupted holds that line. The cost is that expand()/collapse() resolve on these events and nothing else, so the superseded caller's promise is never settled here. That is bounded by the timeout in waitForEvent rather than by dispatching an event that would be a lie — see internal/event.ts.
toggle()Toggles the accordion item's expanded state.

CSS Custom Properties

Learn more about CSS custom properties.

NameDescriptionDefault
--easingThe easing of the expand/collapse animation.var(--cs-transition-easing)
--hide-durationThe duration of the collapse animation.var(--cs-transition-normal)
--show-durationThe duration of the expand animation.var(--cs-transition-normal)
--spacingThe amount of space around and between the item's header and content.var(--cs-space-m)

Custom States

Learn more about custom states.

NameDescriptionCSS selector
animatingApplied while the panel is animating.:state(animating)

CSS Parts

Learn more about CSS parts.

NameDescriptionCSS selector
accordion-itemThe component's outer wrapper.::part(accordion-item)
buttonThe trigger button that toggles the panel.::part(button)
contentThe content slot inside the panel.::part(content)
headingThe heading element wrapping the trigger button. Omitted when heading-level="none".::part(heading)
iconThe container that wraps the expand/collapse icon.::part(icon)
labelThe container that wraps the label.::part(label)
panelThe panel that contains the item's content.::part(panel)

Dependencies

This component automatically imports the following elements. Sub-dependencies, if any exist, are included in this list.