Skip to content

XDSAccordion #188

Closed
Closed

Description

@cixzhang

Spec (revised 2026-02-21)

Accordion is a coordination utility component for collapsible elements. It provides context — no dedicated AccordionItem. Any component that supports isCollapsible can participate.

API

interface XDSAccordionProps {
  /** Single = only one open at a time. Multiple = any number open. */
  type?: "single" | "multiple";  // default "single"
  /** Default open item(s) — uncontrolled */
  defaultValue?: string | string[];
  /** Controlled open item(s) */
  value?: string | string[];
  /** Change callback */
  onValueChange?: (value: string | string[]) => void;
  /** Children — any components that support isCollapsible */
  children: ReactNode;
}

Usage

// Accordion coordinating Cards
<XDSAccordion type="single" defaultValue="general">
  <XDSVStack gap="space2">
    <XDSCard title="General Settings" value="general" isCollapsible>
      <GeneralContent />
    </XDSCard>
    <XDSCard title="Advanced Settings" value="advanced" isCollapsible>
      <AdvancedContent />
    </XDSCard>
  </XDSVStack>
</XDSAccordion>

// Accordion coordinating ListItems
<XDSAccordion type="single" defaultValue="faq1">
  <XDSList>
    <XDSListItem label="What is XDS?" value="faq1" isCollapsible>
      XDS is a design system...
    </XDSListItem>
    <XDSListItem label="How do I start?" value="faq2" isCollapsible>
      Install the package...
    </XDSListItem>
  </XDSList>
</XDSAccordion>

// Multiple open
<XDSAccordion type="multiple" defaultValue={["faq1", "faq2"]}>
  <XDSVStack gap="space2">
    <XDSCard title="Section 1" value="s1" isCollapsible>...</XDSCard>
    <XDSCard title="Section 2" value="s2" isCollapsible>...</XDSCard>
  </XDSVStack>
</XDSAccordion>

// Controlled
const [open, setOpen] = useState<string>("section1");
<XDSAccordion type="single" value={open} onValueChange={setOpen}>
  <XDSVStack gap="space2">
    ...
  </XDSVStack>
</XDSAccordion>

How it works

  1. XDSAccordion renders {children} — no wrapper DOM, just context
  2. Each isCollapsible component checks for Accordion context
  3. If Accordion context exists, the component defers to accordion.isOpen(value) and accordion.toggle(value) instead of managing its own state
  4. If no Accordion context, the component manages its own collapse state
  5. The value prop on each component identifies it to the Accordion

Key decisions

Decision Choice Rationale
No dedicated AccordionItem Coordination only Any isCollapsible component participates. Cleaner, more flexible.
No wrapper DOM Just context provider Accordion doesn't impose layout. Use XDSList, XDSVStack, or nothing.
Works with any component Via isCollapsible + value Cards, ListItems, Sections, PageNavSections — all can participate.
Discoverability concern Address via docs + vibe tests Will run vibe test prompts to see if LLMs can figure it out. If not, add XDSAccordionItem as convenience.

Depends on

Validation plan

Run accordion-related vibe test prompts after implementation. If LLMs struggle with the pattern, add XDSAccordionItem as a convenience wrapper.

Activity

  1. added
    enhancement
    on Feb 19, 2026
  2. added a commit that references this issue on Feb 21, 2026
    05826d3
  3. cixzhang commented on Feb 22, 2026

    @cixzhang
    ContributorAuthor

    Vibe Test Results: Renamed to XDSCollapsibleGroup

    After implementing the accordion as XDSAccordion, vibe tests revealed a discoverability gap (3.0/5 vs shadcn's 4.6/5). Two issues:

    1. "Accordion" name triggered hallucinations — LLMs tried to use AccordionItem/AccordionTrigger by analogy with Radix, which don't exist in XDS
    2. XDSAccordionContext leaked into the component catalog — appeared as a separate component with identical props, confusing the LLM

    Fix: Renamed to XDSCollapsibleGroup

    Dimension XDSAccordion XDSCollapsibleGroup
    "Collapsible" prompts 3/5 5/5
    "Accordion" prompts 5/5 4/5
    Hallucination risk High Low
    Context confusion Yes Fixed
    Overall discoverability 3.5/5 4.7/5

    Why it works better

    • Most prompts describe behavior ("collapsible sections") not pattern names ("accordion"). CollapsibleGroup matches behavioral descriptions.
    • No sub-component hallucination — CollapsibleGroup doesn't imply Radix-style compound components.
    • Context is now internal-only — CLI scanner excludes *Context.tsx files.
    • Categorized under Layout (not "Other") for better shelf placement.

    Implementation

  4. added a commit that references this issue on Feb 22, 2026
    6d35685
  5. added a commit that references this issue on Feb 22, 2026
    e4c2ca9
  6. added a commit that references this issue on Apr 26, 2026
    06f3d70
  7. added a commit that references this issue on Jun 21, 2026
    096ecaf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions