data-display — wyrd.component.accordion

Accordion

Disclosure collection with index-matched content panels.

Install @wyrd-company/react or the Flutter package and use it directly — your DESIGN.md does the styling.

01

Examples

Generated from the contract's examples block. Previews are the published @wyrd-company/react component, themed by the brand's role tokens — flip the site's light/dark toggle and they follow.

Code target Applies to every example on component pages.
faq state: expanded
Generate React and Flutter targets from the same component contract.
Usage
import { useState } from "react";
import { WyrdAccordion } from "@wyrd-company/react/accordion";

export function ControlledAccordionExample() {
  const [expandedValues, setExpandedValues] = useState<readonly string[]>(["targets"]);

  return (
    <WyrdAccordion
      items={[
        { label: "Which targets can I generate?", value: "targets" },
        { label: "Can each product use its own brand?", value: "brands" },
      ]}
      expandedValues={expandedValues}
      onExpandedChange={(event) => setExpandedValues(event.expandedValues)}
    >
      <p>React and Flutter.</p>
      <p>Yes. Products supply brand inputs without forking the catalog.</p>
    </WyrdAccordion>
  );
}
troubleshooting state: expanded
Confirm the property, slot, event, state, and accessibility obligations describe the intended behavior.
Run the catalog generators and review the resulting source changes before editing generated files.
Usage
import { WyrdAccordion } from "@wyrd-company/react";

<WyrdAccordion isMultiple defaultExpandedValues={["contract","generated-files"]} items={[{"label":"Check the component contract","value":"contract"},{"label":"Regenerate derived files","value":"generated-files"},{"label":"Run the parity gates","value":"parity"}]}>
  Confirm the property, slot, event, state, and accessibility obligations describe the intended behavior.
  Run the catalog generators and review the resulting source changes before editing generated files.
  Validate target behavior, accessibility, and visual parity before publishing.
</WyrdAccordion>

// events: onExpandedChange
02

Anatomy

The specimen is the same published React component and contract example used above. Indexed markers identify only regions the contract can ground; the typed ledger keeps parts, slots, states, and semantic token bindings distinct.

ANATOMY · LIVE SPECIMEN Accordion faq example · contract-derived
Generate React and Flutter targets from the same component contract.
  1. Part root Accordion root.

    The complete collection boundary.

  2. Part header Header button.

    The currently expanded item's interactive header.

  3. Part panel Expanded item panel.

    The visible region controlled by the expanded header.

  4. State expanded One or more values are expanded.

    The selected example explicitly starts expanded.

  5. Token panel.background color.surface-container

    The semantic background token applied to the visible panel.

Parts

  • rootAccordion root.
  • itemRepeated item wrapper.
  • headerHeader button.
  • panelExpanded item panel.

Slots

  • contentRequired · one-or-many

States

  • collapsedNo item or this item is collapsed.
  • expandedOne or more values are expanded.
  • focus-visibleKeyboard-visible focus state on a header button.

Tokens

  • header.backgroundcolor.surface
  • header.foregroundcolor.on-surface
  • header.hover-backgroundcolor.secondary
  • header.border-colorcolor.outline
  • header.padding-xspacing.md
  • header.padding-yspacing.sm
  • panel.backgroundcolor.surface-container
  • panel.foregroundcolor.on-surface
  • panel.padding-xspacing.md
  • panel.padding-yspacing.sm
  • border-width1px
  • radiusrounded.sm

FIG. 1 parts: root · item · header · panel TOL. ±0

03

Properties

NameTypeDefaultSummary
items array Ordered accordion headers.
expanded-values array undefined Controlled expanded item values.
default-expanded-values array Initial uncontrolled expanded item values.
is-multiple boolean false Allows more than one item to be expanded at the same time.
04

Slots & events

SlotCardinalityAcceptsSummary
content one-or-many component, content Index-matched accordion panels; the Nth slotted child is the panel body for the Nth item.
EventPayloadSummary
expanded-change expanded-values Emitted with the full new expanded value set after a header activation.
05

Tokens

The contract's token bindings. Open the shared contextual sidebar from any example; primary swatches reflect the color you pick there. Error swatches show the active preset's values; editing any knob switches to custom and resets error to TWW · Ink.

BindingToken
header.background color.surface
header.foreground color.on-surface
header.hover-background color.secondary
header.border-color color.outline
header.padding-x spacing.md
header.padding-y spacing.sm
panel.background color.surface-container
panel.foreground color.on-surface
panel.padding-x spacing.md
panel.padding-y spacing.sm
border-width 1px
radius rounded.sm
06

States

StateSourceSummary
collapsed platform No item or this item is collapsed.
expanded property One or more values are expanded.
focus-visible platform Keyboard-visible focus state on a header button.
07

Accessibility

From the contract's accessibility obligations. Role none

  • Tab moves through accordion header buttons in document order.
  • Enter or Space activates a focused header button using native button behavior.
  • Each header is a button exposing expanded state and controls the matching panel.
  • Expanded web panels expose region semantics labelled by their header.
  • Accordion v1 does not implement arrow-key roving between headers.
  • Verified under: rtl, reduced-motion, cvd-deuteranopia, density-compact, text-expansion.
08

SDUI

Status: serializable. Accordion serializes ordered item records and index-matched panel body content; the Nth serialized content child is the body for the Nth item.

SerializableMembers
Propertiesitems, expanded-values, default-expanded-values, is-multiple
Slotscontent
Eventsexpanded-change
The Wyrding Way — a contract-first design system. © Wyrd Company