Skip to content
Nana UI

Rating

A rating component for displaying and collecting star (or heart/dot) ratings. Supports fractional display, half- and full-step input, multiple symbols, read-only and disabled states, sizes, hover preview, keyboard control and an optional value label.

Terminal window
npm install @nana-tec/ui-components
import "@nana-tec/ui-components/rating";
<nana-rating value="3"></nana-rating>

precision="half" enables half-stars; show-value shows the number; readonly / disabled make it non-interactive.

The variant attribute sets the symbol — star (default), heart, or circle.

PropertyTypeDefaultDescription
valuenumber0Current rating value
maxnumber5Number of symbols
variant'star' | 'heart' | 'circle''star'Symbol shape
precision'full' | 'half''full'Selection granularity
size'xs' | 'sm' | 'md' | 'lg' | 'xl''md'Component size
readonlybooleanfalseDisplay only — no interaction
disabledbooleanfalseDisable interaction and dim the control
clearablebooleanfalseClicking the current value resets it to zero
showValuebooleanfalseShow the numeric value beside the symbols
ariaLabelstring | nullnullAccessible label
EventTypeDescription
nana-changeCustomEventFired when the value is committed (detail.value)
nana-inputCustomEventFired while hovering over a new value (detail.value)
VariableDefaultDescription
--nana-rating-colorActive symbol colour
--nana-rating-empty-colorEmpty symbol colour
--nana-rating-sizeSymbol size (overrides size)
--nana-rating-gapGap between symbols
PartDescription
baseThe root container
symbolsThe symbol group
symbolA single rating symbol
labelThe value label
  • Keyboard accessible
  • Screen-reader labels
  • Focus-visible states
  • ARIA roles and states
  • WCAG 2.2 AA contrast
Explore Rating interactively Every state, prop, and edge case — with live controls — in Storybook.
View in Storybook