Accordions are most often used for hiding and showing sections of related content.

Overview

Accordions can have different selection modes, where users can have multiple or single Accordion Item(s) open.

Sample

Usage

  • To organize related text-based information.
  • To shorten pages and reduce scrolling when content is not crucial to read in full.

Best practices

While similar to a Block, Accordions are not intended to be used within within a Panel.

Accordion is best suited to containing narrative or text-heavy content in the main interactive area of an application, whereas Block is recommended for displaying interactive controls and elements within a Panel.

Do use Accordion to contain related but distinct, primarily text-based content.
Do use Accordion within the main content area of an application to save space.
Avoid using Accordion within a Panel. Instead, use one or more Block(s).
Avoid using Accordion to house interactive controls or form-based components.

Try to avoid placing interactive controls or elements that affect an application state or display within Accordion. These should instead be placed within one or more Block(s). However, in certain instances, it may be appropriate to place interactive controls or form-based elements inside an Accordion - for example, when located within the main content area of a Settings page.

Accessibility

Keyboard navigation

KeyFunction
TabMoves focus to next non-disabled calcite-accordion-item. If the currently focused step is the last step, the focus will leave the component.
Tab and ShiftMoves focus to previous non-disabled calcite-accordion-item. If the currently focused step is the first step, the focus will leave the component.
EnterToggles the expansion of the selected calcite-accordion-item.
SpaceToggles the expansion of the selected calcite-accordion-item.

API reference

Properties

PropertyAttributeDescriptionTypeDefault
appearanceappearance

Specifies the appearance of the component.

Extract<"solid" | "transparent", Appearance>"solid"
iconPositionicon-position

Specifies the position of the expand and collapse icons within calcite-accordion-items

Extract<"start" | "end", Position>"end"
iconTypeicon-type

Specifies the type of the icon in the header.

Extract<"chevron" | "caret" | "plus-minus", IconType>"chevron"
scalescale

Specifies the size of the component.

Scale"m"
selectionModeselection-mode

Specifies the selection mode of the component, where:

"multiple" allows any number of selections,

"single" allows only one selection, and

"single-persist" allows one selection and prevents de-selection.

Extract<"single" | "single-persist" | "multiple", SelectionMode>"multiple"

Slots

NameDescription
default (unnamed)

A slot for adding calcite-accordion-items. calcite-accordion cannot be nested, however calcite-accordion-items can.

Styles

NameDescription
--calcite-accordion-border-color

Specifies the component's border color.

--calcite-accordion-background-color

Specifies the component's background color.

--calcite-accordion-text-color

Specifies the component's text color.

--calcite-accordion-text-color-hover

Specifies the component's main text color on hover.

--calcite-accordion-text-color-press

Specifies the component's main text color when pressed.

Methods

NameDescriptionSignature
componentOnReady

Creates a promise that resolves once the component is fully loaded.

componentOnReady(): Promise<this>

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.