Skip to content
Submitted about 16 hours ago

Interactive rating with native radios, Sass and TypeScript (WCAG AA)

sass/scss, typescript
P
LVL 3
Darkmift•359
@Avi-E-Koenig
A solution to the Interactive rating component challenge

Solution retrospective


What are you most proud of, and what would you do differently next time?

The numbers are native radio buttons in a <fieldset>, hidden visually with their <label>s styled as the circles. That gives the keyboard behaviour for free: Tab reaches the group once, arrow keys choose, and Enter submits the form. After submit, focus moves to the "Thank you!" heading, which has aria-describedby pointing at the "You selected 4 out of 5" pill, so a screen reader announces both. The design has no error state, so submitting with nothing chosen changes nothing visible: a hidden status line asks for a rating and focus goes to the first number. Every text colour in the design passes WCAG AA, and positions match the Figma frames within 2px.

What challenges did you encounter, and how did you overcome them?

WebKit stops matching :focus-visible on a radio once the arrow keys move the selection, so Safari keyboard users lost the focus ring after the first move. The radios use :focus instead, at the cost of the ring also showing after a mouse click.

At 320px with the browser text size at 200%, the row of numbers was 22px wider than the card. Each circle now takes max(2rem, min(42px, a fifth of the row minus the gaps)), so it shrinks to fit and only wraps if even 32px circles don't fit.

I built this together with Claude Code as a pair programmer. I chose the stack and the calls the design left open; Claude read the values from Figma, drafted the code, and ran the layout, keyboard and zoom checks in Chromium, Firefox and WebKit.

What specific areas of your project would you like help with?
  1. Empty submit: with no rating chosen, nothing visible changes; a hidden role="status" line asks for a rating and focus moves to the first number. Is that enough, or would you show a visible message even though the design has none?
  2. Focus ring on the radios: I used :focus instead of :focus-visible because of the WebKit arrow-key issue. Is there a cleaner way to keep the ring for keyboard users in Safari without showing it on mouse clicks?
Code
Loading...

Please log in to post a comment

Log in

Community feedback

No feedback yet. Be the first to give feedback on Darkmift’s solution.

Join our Discord community

Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!

Join our Discord