Segmented ControlLoading saved progress…

Segmented Control

A segmented control presents a small set of mutually exclusive choices and keeps exactly one choice selected. Build the control in React with one selected index so its highlight, accessible state, and status text never disagree.

Signature

Implement the default App component in App.tsx. It takes no props and renders the fixed Day, Week, and Month segments.

Examples

  • On first render, Day has the selected class and aria-selected={true}, while the status reads Selected: Day.
  • Clicking Week moves both the visual highlight and aria-selected={true} to Week, then changes the status to Selected: Week.
  • Clicking Month after Week leaves only Month selected.

Notes

  • Use one state value. Store the selected index with useState(0) and derive every visible result from it.
  • Keep one winner. Compare each segment's index with selected; do not store three independent booleans.
  • Preserve semantics. Keep the role="tablist", role="tab", and aria-selected attributes already present in the starter.
  • Stay in scope. Click selection is required. Arrow-key navigation and a controlled component API are extensions.
  • Leave styles alone. The shared visual treatment lives in styles.css.
WE’RE LISTENING

Help make UIReady better

Found a bug or have an idea? Tell us about it.

Up to 3 files · 5 MiB each · JPG, PNG, WebP, MP4, WebM, MP3, M4A or WAV