Design practice
Build an Accessible Component from Scratch
Implement a fully accessible component with compound patterns and ARIA
01 / Prepare
What you’ll
work on.
Design and implement a disclosure (accordion) component that is fully accessible: keyboard navigable, screen reader compatible, and properly documented. Practice the compound component pattern with ARIA attributes.
Before you begin
- React fundamentals (hooks, composition)
- Basic understanding of ARIA roles and attributes
- Familiarity with keyboard navigation patterns
- A screen reader installed for testing (VoiceOver on macOS, NVDA on Windows)
02 / Practice
The work,
step by step.
Work through these 5 parts at your own pace. Keep your notes and work together so you can review them when you finish.
Research the Pattern
30 min
Read the WAI-ARIA Accordion Pattern at https://www.w3.org/WAI/ARIA/apg/patterns/accordion/
Note the requirements: role="region" on each panel, aria-expanded on trigger buttons, aria-controls linking triggers to panels, keyboard support for Enter/Space to toggle and Tab to navigate between triggers, and optionally Up/Down arrows to move between triggers and Home/End for first/last
Design the API
30 min
Define the compound component API
<Accordion> <Accordion.Item> <Accordion.Trigger>Section title</Accordion.Trigger> <Accordion.Panel>Panel content</Accordion.Panel> </Accordion.Item> </Accordion>Define props: defaultOpen, allowMultiple, onChange
Plan state management: Context-based, no prop drilling
Implement
120 min
Build the compound component with React Context
Implement all ARIA attributes
Implement keyboard handling (Enter, Space, Tab, optionally Up/Down/Home/End)
Add transition animation for panel expand/collapse
Respect prefers-reduced-motion
Test
60 min
Keyboard test — Navigate the entire component without a mouse
Screen reader test — Use VoiceOver/NVDA. Does it announce expanded/collapsed state? Can you navigate by headings?
Contrast test — Check all text meets WCAG AA (4.5:1)
Focus test — Is the focus indicator visible at all times?
Document
30 min
Write a brief component spec: props, keyboard interactions, ARIA attributes
Include a usage example
03 / Review
Look at what
you’ve made.
Gather your deliverables, then use the criteria to find what worked and what you would change. They also give a peer something specific to respond to.
What to bring together
- Working React component (Accordion with compound pattern)
- All ARIA attributes implemented
- Keyboard navigation working
- Screen reader tested (note any issues found)
- Brief component spec document
How to assess your work
- ARIA correctness
- All required attributes present and dynamically updated
- Keyboard
- Full keyboard operation matching WAI-ARIA spec
- Screen reader
- Announces state changes, navigable by region/heading
- Code quality
- Compound pattern with Context, no prop drilling, clean API
- Motion
- Respects prefers-reduced-motion