Skip to main content
cngx-src documentation

CngxAccordionPanel

Directivev0.1.0WCAG AA

projects/common/interactive/accordion/accordion-panel.directive.ts

Import#

import { CngxAccordionPanel } from '@cngx/common/interactive'

Description#

Accordion header. Put cngxAccordionPanel on the header <button>; the directive mirrors aria-expanded from the coordinator, points aria-controls at the region, and toggles the panel on click. It registers a header handle with the coordinator on init (and deregisters on destroy), binds its own roving tabindex, and routes keydown through the coordinator's keyboard-nav factory - so arrow/Home/End navigation works even when a skin renders the header inside its own component view (registration is immune to the contentChildren view boundary).

Expansion state is never owned here: aria-expanded is a computed() over the coordinator's open-set, so single-open arbitration is pure derivation, not sibling syncing (Pillar 1). Use a native <button> so Enter / Space activate it through the browser's own click synthesis.

Metadata#

Host#

Relationships

Index#

Inputs#

controls#string | undefined
input()

id of the region this header controls, bound to aria-controls.

disabled#boolean
input()

Disabled header: skipped by roving, reports tabindex="-1" + aria-disabled="true", and its click never flips the panel open. The visually-hidden aria-describedby reason element is a skin concern owned by the organism, not this brain directive.

default false
panelId#string
input()Required

Stable id identifying this panel within its accordion.

Methods#

handleKeydown#void
Protected
handleKeydown(event: KeyboardEvent)
@parameventKeyboardEvent
ngOnInit#void
toggle#void
Protected

HostBindings#

BindingExpression
[attr.aria-expanded]expanded()
[attr.aria-controls]controls() ?? null
[attr.aria-disabled]disabled() || null
[attr.tabindex]tabindex()

HostListeners#

EventHandler
(click)click()
(keydown)keydown()