OGE logoOGE

Accordion API

Full surface of @oge-ui/layout: the oge-accordion container, the declarative <oge-accordion-item> child with its four template slots, and the config provider.

Properties Methods Events Types

OgeAccordion

oge-accordion

Properties 23

Panels & expansion

Name Type DefaultDescription
itemsreadonly OgeAccordionItemData[] | undefined—Data-driven panels rendered after the projected <oge-accordion-item> children.
expandedKeysreadonly string[][]Keys of the expanded panels — two-way. The multi-expand counterpart of selectedIndex; only panels that declare a key can appear here.
selectedIndexnumber-1Index of the expanded panel in single-expand mode — two-way. -1 means none; in multiple mode it reports the first expanded panel.
multiplebooleanfalseAllows more than one panel to stay expanded.
collapsiblebooleanfalseAllows collapsing the last expanded panel, leaving none open. While false, that header is aria-disabled per the APG — it stays focusable.
disabledbooleanfalseDisables the whole component.

Rendering & animation

Name Type DefaultDescription
deferRenderingbooleantrueInstantiate a panel's content only when it first expands.
keepAlivebooleantrueKeep once-rendered panels mounted (hidden) so their state survives a collapse. Ignored while deferRendering is false.
animationboolean | numbertrueHeight animation: true uses the default duration, a number overrides it in milliseconds, false disables it. Always suppressed under prefers-reduced-motion.

Appearance

Name Type DefaultDescription
togglePosition'start' | 'end''end'Side of the header the chevron sits on — logical, so RTL mirrors it.
hideTogglebooleanfalseHides the chevron entirely. Overridable per panel via <oge-accordion-item [hideToggle]>.
collapsedHeaderHeightstring | undefined—Minimum height of a collapsed header (any CSS length). undefined lets size and the padding tokens decide. Material’s collapsedHeight.
expandedHeaderHeightstring | undefined—Minimum height of an expanded header; falls back to collapsedHeaderHeight. Material’s expandedHeight.
displayMode'default' | 'flat''default'flat removes the gutters between panels and joins them into one stack.
stylingMode'outlined' | 'filled' | 'flat''outlined'Visual variant of the panels.
size'sm' | 'md' | 'lg''md'Density of the header rows.

Keyboard & accessibility

Name Type DefaultDescription
keyboardNavigationbooleantrueEnables Up/Down/Home/End and Ctrl+PageUp/PageDown header navigation. The APG pattern itself requires only Enter/Space and Tab — this is the optional enhancement.
typeAheadbooleantrueEnables printable-character type-ahead over the panel titles. Matching is accent- and locale-insensitive.
selectOnFocusbooleanfalseExpands a panel as soon as keyboard navigation moves focus onto it.
headingLevelnumber3aria-level of the heading wrapping each header button.
useRegionRolebooleantrueGives each panel role="region" (APG-optional; adds one landmark per panel).
ariaLabelstring | undefined—Aria label of the accordion container.
messagesPartial&lt;OgeAccordionMessages&gt;{}Per-instance overrides of the config messages.

Methods 8

Name Type Description
expand(target)(target: number | string) => Promise&lt;boolean&gt;Runs the expand pipeline for the panel at an index or with a key. Resolves true once it expanded, false if an unknown target, itemExpanding or the expandGuard vetoed it.
collapse(target)(target: number | string) => Promise&lt;boolean&gt;Runs the collapse pipeline; resolves whether the panel actually collapsed.
toggle(target)(target: number | string) => Promise&lt;boolean&gt;Expands the panel if collapsed, collapses it otherwise.
expandAll()() => voidExpands every enabled panel. Requires multiple — otherwise it warns in dev mode and does nothing.
collapseAll()() => voidCollapses every panel. In single-expand mode the last panel stays open unless collapsible is set.
expandInvalid()() => voidExpands every panel flagged invalid — call it after a failed form submit so the user sees each section needing attention.
isExpanded(target)(target: number | string) => booleanWhether the panel at an index or with a key is currently expanded.
focus(target?)(target?: number | string) => voidFocuses a panel's header button, or the first enabled one.

Events 11

Name Type Description
itemExpandingOgeAccordionExpandingEventCancelable pre-event of a panel expanding — set cancel = true to block it. Runs before the panel’s expandGuard.
itemExpandedOgeAccordionExpandedEventEmitted after a panel expanded.
itemCollapsingOgeAccordionCollapsingEventCancelable pre-event of a panel collapsing — set cancel = true to block it.
itemCollapsedOgeAccordionCollapsedEventEmitted after a panel collapsed.
afterExpandOgeAccordionExpandedEventEmitted once the expand animation finished — the point at which the panel has its final height. Fires immediately when the animation is off or suppressed by prefers-reduced-motion.
afterCollapseOgeAccordionCollapsedEventEmitted once the collapse animation finished.
itemClickOgeAccordionItemClickEventEmitted when a header button is activated, before the expand pipeline runs. Fires for disabled panels too.
itemContentLoadedOgeAccordionContentLoadedEventEmitted after a panel's contentLoader resolved.
itemContentFailedOgeAccordionContentFailedEventEmitted after a panel's contentLoader rejected.
expandedKeysChangereadonly string[]Two-way model output of expandedKeys.
selectedIndexChangenumberTwo-way model output of selectedIndex.

Types 7

Types

Name Type Description
OgeAccordionItemDatainterfaceData-driven counterpart of a declarative panel: key, title, description, icon, badge, hint, disabled, visible, expanded, invalid, expandGuard, contentLoader.
OgeAccordionExpandGuard() => boolean | Promise&lt;boolean&gt;Veto for a pending expand or collapse. false blocks it; throwing or rejecting is also a veto. While a promise is pending the panel shows a spinner and ignores further toggles (single-flight).
OgeAccordionContentLoader() => Promise&lt;unknown&gt;Loads a panel's content the first time it expands. The resolved value reaches the content template as data.
OgeAccordionTogglePosition'start' | 'end'Chevron side inside the header button.
OgeAccordionDisplayMode'default' | 'flat'Gutters between panels, or one joined stack.
OgeAccordionStylingMode'outlined' | 'filled' | 'flat'Visual variant of the panels.
OgeAccordionSize'sm' | 'md' | 'lg'Density of the header rows.

OgeAccordionItem

oge-accordion-item

Properties 15

Name Type DefaultDescription
titlestring''Header title; alternative to an inline [ogeAccordionHeaderTemplate].
textstring | undefined—Plain-text panel body, rendered when there is no projected content or content template. The reference html item field has no counterpart on purpose.
descriptionstring | undefined—Secondary line rendered under the title.
keystring | undefined—Stable identity used by expandedKeys and DOM ids.
iconstring | undefined—SVG path data (d) rendered as a 24×24 aria-hidden icon before the title.
badgestring | number | undefined—Badge rendered after the title.
hintstring | undefined—Tooltip — rendered as the native title attribute.
disabledbooleanfalseDisabled panels cannot expand and are skipped by keyboard navigation.
visiblebooleantruefalse removes the panel entirely.
expandedbooleanfalseExpanded state of this panel — two-way. Set it to expand on first render, bind it to follow the state, or write to it to drive the panel from outside. Writes still run the pipeline, so a veto reverts the binding.
hideToggleboolean | undefined—Overrides the accordion's hideToggle for this panel.
togglePosition'start' | 'end' | undefined—Overrides the accordion's togglePosition for this panel.
invalidbooleanfalseFlags the section as failing validation — renders the danger rail and feeds expandInvalid().
expandGuardOgeAccordionExpandGuard | undefined—Veto hook run before this panel expands or collapses; may be async (single-flight).
contentLoaderOgeAccordionContentLoader | undefined—Loads this panel's content on first expand, with a skeleton while pending and a retry button on failure.

Methods 3

Name Type Description
open()() => voidExpands this panel. Like a user gesture it runs the accordion’s pipeline, so itemExpanding and expandGuard can still veto it.
close()() => voidCollapses this panel, subject to collapsible and the guards.
toggle()() => voidExpands the panel if collapsed, collapses it otherwise.

Types 5

Template slots

Name Type Description
[ogeAccordionHeaderTemplate]{ $implicit, index, expanded, title, description }Replaces the built-in title/description/icon layout inside the header button. Component-level instances apply to items panels only (queried with descendants: false). Must not contain focusable controls.
[ogeAccordionContentTemplate]{ $implicit, index, data }Panel body; marks the content lazy. data carries the panel's contentLoader result.
[ogeAccordionToggleIconTemplate]{ $implicit: boolean, index }Replaces the chevron. Accordion-level chrome — a component-level instance applies to declarative children too.
[ogeAccordionHeaderActionsTemplate]{ $implicit, index, expanded }Per-panel actions rendered beside the toggle button, never inside it — real focusable controls without a nested-interactive violation.
[ogeAccordionActionRow]directiveMarks a row of buttons at the end of a panel body as its action bar (divider above, actions at the inline end) — the references' action-row slot. Inside the panel, so only reachable while expanded.

Accordion configuration

Properties 6

OgeAccordionMessages

Name Type DefaultDescription
invalidSectionstring'section has errors'Announced after the title of a panel flagged invalid.
pendingstring'working'Announced while an expandGuard promise is in flight.
loadingContentstring'Loading…'Shown while a panel's contentLoader is running.
contentLoadFailedstring'Could not load this section.'Shown when a panel's contentLoader rejected.
retrystring'Retry'Label of the retry button on a failed content load.
noDatastring'No sections to display'Shown in place of the panels when there are no visible items.

Types 5

Behavioural defaults

Name Type Description
hideToggleboolean | undefinedDefault for the hideToggle input.
collapsedHeaderHeightstring | undefinedDefault for the collapsedHeaderHeight input.
expandedHeaderHeightstring | undefinedDefault for the expandedHeaderHeight input. Together with the two above this is the MAT_EXPANSION_PANEL_DEFAULT_OPTIONS equivalent.
Name Type Description
provideOgeAccordionConfig(config)(config: OgeAccordionConfigInput) => ProviderApplication- or component-scoped defaults; shallow-merges messages over the built-ins.
OGE_ACCORDION_CONFIGInjectionToken&lt;OgeAccordionConfig&gt;The token itself, with a factory default — inject it to read the effective config.