Ballmac UI home

Rating Distribution

New

The shape of a set of ratings: the average with partly filled stars, the count, and a bar per star size that can filter the reviews beside it.

v1.0.0Updated Oct 25, 2026Ships with a test
What changed

4.3

2,219 ratings, average 4.3 out of 5

Showing all reviews.

Installation

$ pnpm dlx shadcn@latest add @ballmac/rating-distribution

Usage

import { RatingDistribution } from "@/components/ballmac/rating-distribution"

The full example is in the Code tab above.

Examples

Few ratings

4.7

16 ratings, average 4.7 out of 5

  • 51275%
  • 4319%
  • 316%
  • 200%
  • 100%

API reference

PropTypeDefault
counts*

How many ratings of each size.

RatingCounts—
selected

The selected size, to filter reviews with. Controlled.

1 | 2 | 3 | 4 | 5 | null—
onSelect

Makes each row a button. Called with the size, or null when it is cleared.

(rating: 1 | 2 | 3 | 4 | 5 | null) => void—

Also accepts the standard attributes of its root element.

Accessibility

KeyAction
SummaryThe average and total are text; the stars are decoration
RowsButtons named '4 stars: 2 ratings. Show only these' with pressed state
CountsShown as numbers and percents beside each bar

Use with AI

counts is { 1, 2, 3, 4, 5 } (how many of each). The average and total are computed and written as text. onSelect(rating | null) with selected makes each row a toggle button for filtering a review list. With the shadcn MCP server set up (guide), ask your agent:

Add the Ballmac UI Rating Distribution (@ballmac/rating-distribution) to this project with the shadcn MCP, then use it where it fits.

Use it for

  • Above a list of product, app or course reviews
  • A feedback summary

Not for

  • Collecting a rating; use rating
  • Satisfaction over time; use chart-line

Registry JSON: https://ui.ballmac.com/r/rating-distribution.json

Credits

Free to use in personal and commercial projects.

Ballmac UI Pro

Need the whole screen, not one piece?

150 premium blocks (dashboards, settings, calendars, mail, shops, onboarding), a private shadcn registry and Figma tokens. Blocks that show data come with loading, empty and error states built in.

Not ready? Try three Pro blocks free

Leave your email and the blocks appear right here, ready to copy. Yours to use in any project.