Rating
One star, the average score and an optional compact count ("4.8 · 2.1K workspaces"), with built-in English and Arabic screen reader text.
Code
import { Rating } from "@fadymondy/nasaq/web";export function AppRating() { return <Rating value={4.8} count={2140} countLabel="workspaces" />;}Storefront · beta
Live examples and controls: Rating in the lab.
Install
npx shadcn@latest add https://docs.nasaqui.com/r/rating.jsonShows an average score as a single star, the number, and optionally how many people rated or use the thing: "★ 4.8 · 2.1K workspaces". It is one star, not five, because a row of part-filled stars is hard to read at small sizes and says nothing the number does not. It is read-only.
When to use
- A store listing, product card or app detail header.
- An average score with an optional count.
When not to use
- Collecting a rating from the user: build it with buttons or a radio group;
Ratingis display only. - A status or state: use
Status. - A label such as "New" or "Pro": use
Badge.
Import
import { Rating, type RatingProps } from "@fadymondy/nasaq/web";
// inside this monorepo: "@nasaq/web"Quick start
import { Rating } from "@fadymondy/nasaq/web";
export function AppRating() {
return <Rating value={4.8} count={2140} countLabel="workspaces" />;
}Anatomy
Rating data-slot="rating" <span>
├─ sr-only text full sentence for screen readers
├─ star lucide Star, aria-hidden
├─ score <bdi>, one decimal
└─ count (optional) "·", <bdi> compact count, countLabel; aria-hiddenAPI
Rating
RatingProps extends Omit<ComponentProps<"span">, "children">. Remaining props go to the outer <span>.
| Prop | Type | Default | Description |
|---|---|---|---|
value | number | required | Average score, for example 4.8. Always shown with one decimal. |
max? | number | 5 | Top of the scale. Used in the screen reader text only ("out of 5"). |
count? | number | none | How many people or workspaces rated or use it. Shown compact: 2.1K. Omit to hide. |
countLabel? | string | none | What count counts: "workspaces", "reviews". Localise it. |
className? | string | none | Merged onto the outer span. |
Examples
Score only
import { Rating } from "@fadymondy/nasaq/web";
export function Score() {
return <Rating value={4.6} />;
}Arabic listing
import { NasaqProvider, Rating } from "@fadymondy/nasaq/web";
export function ArabicRating() {
return (
<NasaqProvider locale="ar" dir="rtl">
<Rating value={4.8} count={2140} countLabel="مساحة عمل" />
</NasaqProvider>
);
}Accessibility
- A
sr-onlysentence carries the meaning: "Rated 4.8 out of 5, 2.1K workspaces". The visible star, score and count arearia-hiddenso they are not read twice. - Without a
NasaqProviderthe sentence is English. With anarlocale it reads in Arabic ("التقييم 4.8 من 5"). - No keyboard interaction; it is not focusable.
- Localise
countLabelyourself.
RTL & i18n
- Layout uses
inline-flexand logical spacing (me-1.5), so the star stays on the inline start in both directions. - The score and count are wrapped in
<bdi>, so digits keep their order inside Arabic text. - Numbers go through the Nasaq number formatter (
useFormatNumber), so the numeral set and compact notation follow the active locale. - Built-in strings: the screen reader sentence in English and Arabic.
countLabelis yours.
Styling & tokens
- Tokens:
text-nq-accent(star, filled),text-muted-foreground(count),text-foreground(score),text-caption. - Target with
[data-slot=rating]. - Extend with
className. The count truncates when space is tight.
Do / Don't
- Do pass a
countLabelwhen you passcount, so the number means something. - Do keep the star single; it reads at every size.
- Don't use it as an input.
- Don't show a score without saying what it averages when it is not obvious.
Related
- Price · ProductCard · Badge
Lab
https://docs.nasaqui.com/?path=/docs/components-storefront-rating--docs
ProductReviews
Customer reviews for a product: rating summary with a histogram that filters, sort and filter chips, photo strip, helpful votes, seller replies, report, and a write-review form. Includes ProductQA for questions and answers.
StoreOrderHistory
The customer's store account. Order history with status filters and reorder, an order page with the tracking timeline and a carrier link, a return and refund request flow with RMA status, a wishlist with move to cart and back-in-stock notify, an address book and recently viewed products. The reorder, return and wishlist rules are pure and tested.