Component / Layout

Animated Accordion

Reveal variable-height detail with stable trigger and region semantics, retained closing content, interruption-safe transitions, and complete keyboard navigation.

Expansion
System details / controlled

The panel measures its rendered body, animates to that exact height, then restores authored styles.

State
Retained
Cleanup
Scoped

Delivery contract

Install it

pnpm add easecraft@0.1.0

The component imports stable APIs from easecraft.

Files / 00

    Dependencies / 03

    easecraft
    npm / 0.1.0
    react
    peer / >=18.2.0 <20.0.0
    react-dom
    peer / >=18.2.0 <20.0.0

    Package usage

    Use it

    import { AnimatedAccordion } from "easecraft";
    
    <AnimatedAccordion
      aria-label="Project details"
      items={details}
      getValue={(detail) => detail.id}
      getLabel={(detail) => detail.label}
      defaultValue="overview"
    >
      {(detail) => <ProjectDetail detail={detail} />}
    </AnimatedAccordion>

    Typed contract

    API

    PropTypeDefaultPurpose
    itemsreadonly Item[]requiredAccordion item data
    getValue(item) => stringrequiredStable item value
    getLabel(item) => ReactNoderequiredTrigger label renderer
    children(item) => ReactNoderequiredPanel renderer
    mode"single" | "multiple""single"Expansion model
    valuestring | readonly string[]uncontrolledControlled expanded values
    defaultValuestring | readonly string[]noneInitial expanded values
    onValueChangemode-dependent callbacknoneExpansion change callback
    collapsiblebooleantrueAllow all single panels to close
    disabledbooleanfalseDisable the full accordion
    isDisabled(item) => booleannoneDisable individual items
    headingLevel2 | 3 | 4 | 5 | 63Semantic trigger heading
    durationduration token | number"normal"Opening duration
    easingeasing token | string"enter"Opening easing
    exitDurationduration token | number"fast"Closing duration
    exitEasingeasing token | string"exit"Closing easing
    asHTML tag"div"Polymorphic host element

    Release requirement

    Accessibility

    Semantic linkage
    Every heading trigger controls one persistently identified, labelled region.
    Keyboard
    Arrow keys, Home, End, Enter, and Space follow the accordion APG pattern.
    Retained exit
    Closing content becomes inert and hidden from assistive technology before exit.
    Focus safety
    Programmatic closure moves focus from panel content back to its trigger.
    Reduced motion
    Expanded state and semantics settle immediately without creating an animation.
    Server rendering
    Default expanded content and closed panel semantics render deterministically.