Skip to content
Vertical Jump Designs-uiFront-End Studio
Get Pro

v3.9 is out.

Data display

RatingBreakdown

Free12.0 KB gzipped

The summary above a review list: the average rating as a big number with stars, the review count, and one bar per level showing its share. Each row reads "5 stars: 920 reviews, 72%"; with onLevelSelect the rows are toggle buttons for filtering by level.

Accessibility: WCAG 2.2 AA · No A or AA violations in light or dark mode · Keys: Tab, Enter, Space · Full report

More in Pro

This RatingBreakdown is free. ReviewsSection, in the paid Pro add-on, uses it as the summary of a complete reviews section, where its rows filter the list.

Import

tsx
import { RatingBreakdown } from "@vjdesigns/vjdesigns-ui";

Importing only RatingBreakdown adds about 12.0 KB of minified, gzipped JavaScript to your app (React not included). The stylesheet is shared by every component and loaded once: 75.1 KB gzipped.

Examples

Basic

The average, the review count and one bar per star level. Each row reads "5 stars: 920 reviews, 72%" to screen readers. average and total are worked out from counts when you leave them out.

Based on 1,284 reviews92% would recommend
  • 5 stars: 920 reviews, 72%
  • 4 stars: 210 reviews, 16%
  • 3 stars: 80 reviews, 6%
  • 2 stars: 40 reviews, 3%
  • 1 star: 34 reviews, 3%
tsx
import { RatingBreakdown } from "@vjdesigns/vjdesigns-ui";

export function Basic() {
  return (
    <div style={{ width: "100%", maxWidth: "26rem" }}>
      <RatingBreakdown counts={{ 5: 920, 4: 210, 3: 80, 2: 40, 1: 34 }} recommendPercent={92} />
    </div>
  );
}

Filter by level

With onLevelSelect, each row is a toggle button (aria-pressed) for filtering reviews by star level. Press the selected row again to clear the filter.

Based on 100 reviews

Showing all reviews

tsx
import { useState } from "react";
import { RatingBreakdown, Stack, Text } from "@vjdesigns/vjdesigns-ui";

export function FilterByLevel() {
  const [level, setLevel] = useState<number | null>(null);
  return (
    <Stack gap={3} style={{ width: "100%", maxWidth: "26rem" }}>
      <RatingBreakdown counts={{ 5: 64, 4: 22, 3: 9, 2: 3, 1: 2 }} selectedLevel={level} onLevelSelect={setLevel} />
      <Text tone="muted">{level === null ? "Showing all reviews" : `Showing ${level}-star reviews`}</Text>
    </Stack>
  );
}

Inline

layout="inline" puts the average beside the bars, and wraps on narrow screens.

Based on 193 reviews
  • 5 stars: 120 reviews, 62%
  • 4 stars: 48 reviews, 25%
  • 3 stars: 15 reviews, 8%
  • 2 stars: 6 reviews, 3%
  • 1 star: 4 reviews, 2%
tsx
import { RatingBreakdown } from "@vjdesigns/vjdesigns-ui";

export function Inline() {
  return (
    <div style={{ width: "100%", maxWidth: "40rem" }}>
      <RatingBreakdown layout="inline" counts={{ 5: 120, 4: 48, 3: 15, 2: 6, 1: 4 }} />
    </div>
  );
}

Right to left

The first example again, inside a right-to-left LocaleProvider (Arabic). Layout, spacing and arrow icons mirror, and the components' built-in text is translated. The example's own text stays in English.

Basic

استنادًا إلى 1,284 مراجعة92‎%‎ يوصون به
  • 5 نجوم: 920 مراجعة، 72‎%‎
  • 4 نجوم: 210 مراجعات، 16‎%‎
  • 3 نجوم: 80 مراجعة، 6‎%‎
  • نجمتان: 40 مراجعة، 3‎%‎
  • نجمة واحدة: 34 مراجعة، 3‎%‎
tsx
import { LocaleProvider } from "@vjdesigns/vjdesigns-ui";
import ar from "@vjdesigns/vjdesigns-ui/locales/ar";

// Basic is the "Basic" example above.
<LocaleProvider locale="ar" messages={ar}>
  <Basic />
</LocaleProvider>

API reference

RatingBreakdown

New in 3.8.4
RatingBreakdown props
PropTypeDefault
countsRequired

Reviews per level, e.g. { 5: 920, 4: 210, 3: 80, 2: 40, 1: 34 }. Missing levels count as 0.

Record<number, number>—
average

The average rating. Computed from counts when omitted.

number—
total

Total reviews. The sum of counts when omitted.

number—
max

The highest level (number of stars).

number5
onLevelSelect

Called when a level row is pressed, with that level, or null when the pressed row is pressed again. Turns each row into a toggle button for filtering a review list.

(level: number | null) => void—
selectedLevel

The level currently filtered on (shown pressed). Use with onLevelSelect.

number | null—
recommendPercent

Share of reviewers who would recommend, 0 to 100. Shown as "92% would recommend".

number—
layout

stacked: the average above the bars. inline: beside them (wraps on narrow screens).

"stacked""inline""stacked"
size

Text size.

"sm""md""lg""md"

Also accepts native <div> attributes, plus className, style and ref.

See what changed in each version in the Changelog.

Accessibility report

RatingBreakdown targets WCAG 2.2 AA. Below: a live axe-core audit of this page's examples, Lighthouse scores for the page in both modes, the accessibility behavior built into the component, and the checks only a person can do.

axe-core audit (live)

Running accessibility audit

Checking the examples above…

Lighthouse audit

Light mode

Score 100

35 passed · 0 failed · 30 not applicable · 10 to check by hand

Dark mode

Score 100

35 passed · 0 failed · 30 not applicable · 10 to check by hand

Lighthouse 13.5.0 audits the whole docs page (header and sidebar included), not just the examples, in English. Last run 11/27/2026. Some failed audits carry no weight in the score, so a page can score 100 and still list one.

Built-in behavior

Keyboard

Keyboard
KeyAction
TabWith onLevelSelect: moves through the level rows.
EnterSpaceFilters by that level, or clears the filter on the pressed row.

Roles and states

Roles and states
ElementRoleStates and properties
Levelslistaria-label ("Rating distribution")
Level rownone (or button)Read as "5 stars: 920 reviews, 72%"; with onLevelSelect a toggle button with aria-pressed
Big average, bars and percentsnonearia-hidden; the same values are in the text read aloud

Manual checks

Automated tools find roughly a third of accessibility issues. Test these in your app, with your content.

Manual accessibility checks
CheckWhat to testWCAG 2.2
KeyboardEvery action works with Tab, Shift+Tab, Enter, Space and the arrow keys, and focus never gets stuck.2.1.1 (A), 2.1.2 (A)
FocusFocus moves in a logical order, is always visible, and isn't hidden behind sticky headers.2.4.3 (A), 2.4.7 (AA), 2.4.11 (AA), 2.4.13 (AAA)
Screen readersNames, roles and states are announced correctly, and status changes are announced without moving focus.1.3.1 (A), 4.1.2 (A), 4.1.3 (AA)
ColorMeaning never depends on color alone; your own colors meet contrast in both modes.1.4.1 (A), 1.4.3 (AA), 1.4.11 (AA), 1.4.6 (AAA)
Zoom and reflowAt 200% text size and at 320px wide (400% zoom), nothing is cut off and no sideways scrolling is needed.1.4.4 (AA), 1.4.10 (AA), 1.4.12 (AA)
Pointer targetsClick and tap targets are at least 24×24px (44×44px for AAA), or spaced so they don't overlap.2.5.8 (AA), 2.5.5 (AAA)
MotionAnimations respect the reduced-motion setting.2.3.3 (AAA)