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

Solution retrospective
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.
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?- 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? - Focus ring on the radios: I used
:focusinstead of:focus-visiblebecause 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?
Please log in to post a comment
Log in with GitHubCommunity 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