Color Swatch PickerLoading saved progress…

Color Swatch Picker

Build a React color picker whose selected color drives a preview, a hex label, and the highlighted swatch. The fixed six-color palette already renders in the starter. Your job is to add one state value and connect the buttons to it.

Signature

Implement the default-exported App component in App.tsx. It receives no props. Track the chosen hex string with useState, starting at COLORS[0], and update it from each swatch button's onClick.

Examples

  • The page loads with the red swatch ringed, the preview red, and the label reading #ef4444.
  • Clicking the green swatch turns the preview green, updates the label to #22c55e, and moves the ring onto the green swatch.
  • Clicking the selected swatch again keeps the same preview and selection.

Notes

  • One value, four outputs. Derive the preview, label, selected class, and aria-pressed from selected.
  • The swatch colors are a fixed palette. They live in a constant array and set each swatch's background via an inline style; only the selected one changes.
  • Keep buttons accessible. Preserve each button's aria-label and update aria-pressed from the same state.
  • Leave styling alone. The dark theme, preview, swatches, and ring are already 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