Skip to content

BbRating

Collect a whole-number rating as a radio group or display an existing score.

import { BbRating } from 'bitboss-ui';

On this page

Use it for

Use BbRating for a small whole-number judgement such as an order review.

Use something else when

Also see: Validated forms.

Passthrough

Hover or tap a part to outline it. The toggles turn on loading, errors and warnings where the component has them; only parts get a row.

Shown under the label as lasting context.
Guidance while the control is focused.

Validate an order review

Inside a BbForm the rating joins the form under its name. Give it a legend and rules="required", a rule you register once that refuses null: the form blocks the submit and moves focus to the stars.

Rate your orderOrder #10482, delivered on 8 July 2026.

On a rating joined to a form the rule is the requirement, and it also marks the legend. required there is only a hint: it marks the legend and checks nothing. Outside a form, required is the prop to use.

The stars are native radio inputs: Tab enters the group once and arrow keys change the value. Without a name, the form keys the value by the legend, so pass one.

Clear and choose the scale

clearable adds the only path back to unrated: click the selected star again or press Delete or Backspace.

Rate your order3 of 5
Click the picked star or press Delete to clear.

The cleared value is null, never 0. Explain the gesture in a hint that stays visible (persistent-hint). stars changes both the number of choices and maximum value; beyond about ten, prefer labels or a slider.

Display an existing score

Use readonly for a score people may inspect; unlike disabled, it stays in the tab order.

Anchor USB-C Dock, 11-in-1

Average rating for Anchor USB-C Dock, 11-in-14.3 · 128 reviews
Your ratingYou can rate it once your order arrives.

There are no half stars. Round for the stars and print the precise decimal and sample size in the append slot.

Size, icon and colour

size takes the shared scale, xs to 2xl; md is the default. Use sm or xs for a score inline with text.

xs
Rating, size xs
sm
Rating, size sm
md
Rating, size md
lg
Rating, size lg
xl
Rating, size xl
2xl
Rating, size 2xl

Colour the stars by setting three variables on the root (a class or pt:root), never with a text-colour class: --accent for a filled or previewed star, --empty for an unfilled one, and --border-color for the outline. The outline defaults to var(--bb-text-faint); set --border-color: transparent for a glyph with no outline.

How was your stay?
How much do you love this release?

The icon slot swaps the star and passes size as a CSS length and checked on every lit star; pass size straight to BbIcon. A colour class on the icon or pt:item freezes the hover preview (bitboss-ui/no-star-color flags it); keep pt:item for spacing and pt:item:selected="drop-shadow-sm".

Coming from v2color → --accent

The removed color prop becomes --accent on the root. input-position, which did nothing in v2, now aligns the stars: delete any alignment workaround.