Rating

How the Rating works with a keyboard and assistive tech, and where it stands against WCAG 2.2 AA.

FreeReact and VueRating blocks12 blocksPro
AAWCAG 2.2 target
9/18contrast pairs passing
6keyboard interactions

Rating comes in two kinds. Read-only, the Rating & Review summary is a role="img" labelled "Rated 4.5 out of 5", and each distribution row is a role="meter". Interactive, Rating Cells and the Rating Bar are radio groups with one tab stop: arrow keys move the choice, and each radio is named "3 stars" or "3 of 5".

Keyboard#

Tab

Moves into the group, onto the chosen radio (or the first), then out of it in one step.

→+↑

Chooses the next score and moves focus to it.

←+↓

Chooses the previous score and moves focus to it.

Home

Chooses the lowest score.

End

Chooses the highest score.

Space

Chooses the focused score.

Semantics#

role="radiogroup" aria-label

Named from ariaLabel, such as "Rate this template".

Rating Cells, Rating Bar
role="radio" aria-checked

Named "1 star" to "5 stars" (or hearts), or "1 of 5" on the Rating Bar. Emoji are decorative (alt="").

Each cell or step
aria-readonly, aria-disabled

On the group. Disabled cells leave the tab order.

readOnly, disabled
role="img" aria-label

"Rated 4.5 out of 5". Everything inside is presentational, including the count and the reviews link.

Rating & Review
role="meter"

The track carries aria-valuenow and is named by its label, such as "5 Stars".

Distribution row

Colour contrast#

Every variant and state has to meet WCAG 2.2 Level AA. Measure the colours as they land on screen: a translucent hover or press wash over whatever sits behind it.

3:1

Marks · Rest, Hover, Selected

Stars and hearts are graphics: 3:1 against the cell. Empty marks (#f2f2f2) and hover previews (#cbcbcb) fall well short, so the chosen score must also be readable another way.

WCAG 1.4.11 Non-text Contrast ↗WCAG 1.4.1 Use of Color ↗
4.5:1

Numbers and text · Rating Bar, summary

Number steps, the average, the count and the reviews link are text at 14px.

WCAG 1.4.3 Contrast (Minimum) ↗
3:1

Distribution fill · Rating Progress

The yellow fill (#fdda2a) against its 8% track measures 1.16:1. The count or percentage beside it carries the value.

WCAG 1.4.11 Non-text Contrast ↗
3:1

Focus indicator · Focus visible

#1a6ef8 (4.54:1 on white): a 2px ring with a white gap around Rating Cells, inset on Rating Bar steps and the reviews link.

WCAG 1.4.11 Non-text Contrast ↗WCAG 2.4.13 Focus Appearance ↗
Required

Name and state · Interactive

Each radio says its score and whether it is chosen, so the value never depends on counting filled stars.

WCAG 4.1.2 Name, Role, Value ↗

Measured contrast#

Marks and text against the cell they sit on, at rest, on hover and chosen, from the rating tokens. Marks are graphics and are held to 3:1; numbers and text are held to 4.5:1. The summary has no hover or chosen state, so it repeats its rest figure. 9 of 18 pairs fall below their minimum (4.5:1 for text, 3:1 for graphics) and are marked in amber.

Part · markRestHoverSelected
Rating Cell · Star1.12below the minimum1.49below the minimum2.27below the minimum
Rating Cell · Heart1.12below the minimum1.49below the minimum4.49passes
Rating Bar · Number3.23below the minimum14.35passes12.82passes
Rating Bar · Star1.62below the minimum1.62below the minimum2.27below the minimum
Rating & Review · Average, count14.35passes14.35passes14.35passes
Rating & Review · Reviews link5.17passes14.35passes5.17passes

Motion#

  • Cell washes, mark fills and Rating Bar fades take 150ms and are turned off under prefers-reduced-motion.

Checklist#

The reviews link sits inside the summary's role="img", so it is focusable but has no name for screen readers. Move it outside the image.

The summary's "5.2K Ratings" is hidden by the same role="img". Put the count in the label ("Rated 4.5 out of 5, from 5,200 ratings") or outside the image.

Empty marks are about 1.1:1 and hover previews about 1.6:1. Show the chosen score in text as well ("3 of 5").

Stars (#ff9000) measure about 2.3:1 on white, under 3:1. Hearts pass at about 4.5:1.

Rating Bar numbers at rest are #8f8f8f, about 3.2:1. Darken them.

Arrow keys choose as they move, like native radios. If a choice sends something, add a separate submit.