<NbRating v-model="quality" label="Quality" />When to use it
- To show a score on a short, fixed scale: a quality score, a difficulty.
- To let someone set that score in one gesture.
- Not for a number on a long or open scale: that is
NbSliderorNbNumberInput. - Not for a choice between named options: that is a radio group.
Read only
readonly draws the stars and takes no input. It is one image to assistive technology, named by the label and the value: "Quality, 4 of 5 stars". A fraction, such as an average, draws to the nearest half star and is announced as given.
<NbRating :model-value="4" label="Quality" readonly />
<NbRating :model-value="3.5" label="Average" readonly />Clearable
null means not rated. With clearable, a clear button follows the stars while there is a rating, and Delete or Backspace clears it from the keyboard. Without it, a rating once set can be changed but not removed.
<NbRating v-model="override" label="Override" clearable />Sizes
sm, md (the default) and lg draw the stars at 16, 20 and 24px, the icon scale. On a phone touch screen every star is a 44px target, at any size.
Disabled
disabled keeps the rating in place, dimmed, and out of the tab order.
More or fewer stars
max sets the scale. Keep it short: past five or so a row of stars stops reading at a glance.
Light and dark
Filled stars are the fill weight in the text colour and empty ones the outline in the muted text colour, so they follow the theme, and they differ in shape as well as tone. Switch the docs theme to see both.