Theme studio

Design a theme, preview it live, then export it. Saved in this browser.

Quick picks #10b981
Generated scale
50100200300400500600700800900
Some text is below AA

RatingSummary

  • Stable
  • WCAG 2.2 evidence
  • RTL

Summary of survey or review ratings: the average with its stars and the number of responses, next to the share of each star level. Presentational: renders in React Server Components. Every bar has its percentage as text and every level is named ("5 stars"), so nothing depends on bar length or colour (WCAG 1.1.1, 1.3.1, 1.4.1); the distribution is a list. The card is a size container: the average stacks above the distribution below 480 px and sits beside it from there (WCAG 1.4.10). Text wraps. Consumer duties: do not show a summary for fewer than 5 responses; translate label, levelLabel, total; format numbers for the locale; put a heading before the card.

import { RatingSummary } from "@nexera-ui/react";
Loading example…
4
examples
6
props
1
live controls
1
platform
6
WCAG criteria
1
block uses it

Try every prop. Copy the code.

Change the props and the code updates. Check light and dark, LTR and RTL, and phone width.

Loading…
label
Generated code
import { RatingSummary } from "@nexera-ui/react";

<RatingSummary />

Examples 3

The same examples as Storybook, rendered live. Open Code to copy one.

Narrow container

Below a 480 px container the average stacks above the distribution.

Loading example…

Long content

Long totals and translated row names wrap.

Loading example…

Right to left

Right-to-left: bars grow from the right; level names, percentages and the rating label are translated.

Loading example…

Props 6

Press "Try it" on a card to load that prop into the playground.

6 props shown

value*Nexera
number

Average rating from 0 to 5. Drives the stars (rounded to the nearest half) and their text alternative.

Default –
averageNexera
ReactNode

Visible average, for example "4.3" formatted for your locale. The stars' text alternative already says it, so this text is hidden from assistive technology.

Default `value` with one decimal
totalNexera
ReactNode

Number of responses, for example "212 responses". Shown when provided.

Default –
distribution*Nexera
readonly RatingSummaryBucket[]

Rows of the distribution, in display order. Each row shows its percentage as text.

Default –
labelNexera
string

Text alternative of the stars. Translate it.

Default "<value> out of 5", for example "4.3 out of 5"
levelLabelNexera
(stars: number) => string

Accessible name of a row's level, read before its percentage ("5 stars, 58%"). Translate it, with your locale's plural rules.

Default (stars: number): string => stars === 1 ? "1 star" : `${String(stars)} stars`

* Required. React Aria props shown are the ones most apps use; the component accepts the rest of its React Aria props too.

Accessible by default.

Built on React Aria, and covered by the WCAG 2.2 evidence generated on every build.

WCAG 2.2 evidence

4 direct · 2 supporting
  • 1.1.1Non-text ContentLevel A · tested directly
  • 1.3.1Info and RelationshipsLevel A · tested directly
  • 1.4.1Use of ColorLevel A · tested directly
  • 1.4.10ReflowLevel AA · supporting test
  • 1.4.12Text SpacingLevel AA · supporting test
  • 4.1.2Name, Role, ValueLevel A · tested directly

Fits any width.

Nexera components respond to the space they are given. Drag the corner of the frame, or pick a width.

0 px · drag the corner

Styling hooks

Pass className to add Tailwind classes (merged last). State is exposed as data attributes, so you can style it with variants like data-pressed:.

Usage
<RatingSummary className="shadow-sm" />

Used in blocks

Related components