Home
← All questions

Accordion component | Frontend Machine Coding

EasyPremiumMachine Coding

Asked at Amazon · Shopify · Google

Frontend Machine Coding interview practice: Build a single- or multi-expand accordion with keyboard navigation.

Problem

Build an accordion for FAQ sections.

Requirements

  • List of { id, title, content } items.
  • Click header to expand/collapse panel.
  • Single-expand mode (default) or multi-expand mode.
  • aria-expanded, aria-controls, animated height optional.
  • Arrow Up/Down moves focus between headers.

Hints / Approach

  • State: Set of open ids (multi) or single openId string.
  • Panel visibility: conditional render or CSS max-height transition.
  • Header is <button> inside <h3> per WAI-ARIA accordion pattern.
Premium question

Unlock the in-browser editor, test cases, and model solution with Mentoxis Premium.

Unlock with Premium