Build a Reusable Single-Select Accordion Component
In ServiceNow's Now Experience, building robust and reusable UI components is crucial for delivering intuitive and efficient user interfaces. One common pattern is the Accordion, used to manage space and present categorized information cleanly. For this problem, you will implement a single-select Accordion component, focusing on reusability, state management, and accessibility, which are key considerations in enterprise-grade UI development.
Your goal is to create a Accordion React component that displays a list of collapsible items. The component should adhere to the following requirements:
Accordion component that accepts an array of data, and an AccordionItem sub-component to render individual collapsible sections.Space or Enter keys should toggle the active accordion item when its header has focus.ArrowDown and ArrowUp keys should move focus between accordion headers.Home key should move focus to the first accordion header.End key should move focus to the last accordion header.Accordion component correctly renders all provided items.Space and Enter keys correctly toggle the focused header's content.ArrowDown, ArrowUp, Home, and End keys correctly manage focus between headers.aria-expanded, aria-controls, role, tabIndex) are used for accessibility.Constraints
title (string) and content (string or JSX.Element).Accordion and AccordionItem components are structured, how props are passed, and their reusability.Loading editor...