Bonusway design system

Data display

Rating

Stars, read-only by default. Passing onChange turns it into an input — the same component, because a review form and a review listing must not disagree about what 4.5 looks like.

import Rating from '@/components/ui/Rating';

Source: src/components/ui/Rating.tsx

Examples

Fractions render as partial stars

Sizes

Props

<Rating> props

PropTypeDefaultDescription
valuerequirednumber——
maxnumber5—
size'sm' | 'md' | 'lg''md'—
onChange(value: number) => void—

Providing onChange makes the stars clickable (whole stars only).

classNamestring''—

Accessibility

  • Read-only: the value is exposed as text, not as five images.
  • With onChange it becomes a radio group — arrow keys move between stars, and each has a label.

Usage

Do

  • Show the review count next to it; a bare 5.0 from one review is misleading.

Don’t

  • Don’t round a 4.4 up to 4.5 for display — the partial star exists so you don’t have to.

Related:Progress

Šī lapa lieto sīkfailus

Mēs izmantojam sīkfailus, lai uzlabotu tavu pieredzi mūsu vietnē un pielāgotu saturu, ko mēs tev piedāvājam. Būtiski sīkfaili ir nepieciešami, lai mūsu pakalpojums darbotos pareizi. Ja esi priecīgs, ka mēs apkopojam informāciju, izmantojot mārketinga sīkdatnes, tad izvelies “Pieņemt visu”. Vienmēr vari mainīt minētos iestatījumus, apmeklējot sīkfailu iestatījumus.

Sīkfailu iestatījumi