Command Palette

Search for a command to run...

Hectal
Phase 0: Start Here: Why React
React · Exercise 5 of 5 Previous
Beginner

Mini build: a mood picker

Build a mood picker with three buttons labelled Happy, Calm and Sad, and a paragraph with id="mood".

At the start the paragraph says You feel: nothing yet. Clicking a button changes it to You feel: Happy (or Calm, or Sad).

The chosen button has aria-pressed="true"; the other two have aria-pressed="false". (Screen readers announce aria-pressed buttons as toggle buttons.)

What Check tests

  1. There are three buttons: Happy, Calm and Sad
  2. It starts with You feel: nothing yet
  3. Clicking Calm shows You feel: Calm
  4. Only the chosen button has aria-pressed="true"
  5. Choosing again moves the selection

Stuck? One hint at a time

The solution unlocks after your first Check. Try first: that is where the learning happens.

Runs in your browser. Your code is saved here.

Your page

Press Run to see the page.

Console

Nothing logged yet.