Community project. This is not an official government website.

Run by volunteers. Lampung Design System is built by an open source community. No government agency runs or endorses it.

Official services use go.id. Government websites in Indonesia end in .go.id. Never enter your national ID number on a site you are unsure of.

Rating

Rating

Five stars for rating something from one to five. Hovering previews the score, clicking sets it; it works as a radio group from the keyboard.

Usage

Use it when

  • People rate a course, a lecturer, an explanation or a tryout from one to five.
  • Showing an average rating read-only next to a title (static stars without buttons).

Use something else when

  • A quick yes or no on usefulness ("Was this explanation helpful?"): use Button group. Two buttons, or a like for a single positive.
  • A score on a wider scale (0 to 10, a percentage): use Slider.
  • Showing a score as progress or a level: use Meter.
  • Choosing one of a few named levels (Easy, Medium, Hard): use Segmented control.

Where it goes. At the end of the thing rated: after a finished course or tryout, in a review form, in a feedback sheet on phones. Read-only ratings sit next to the title or in a key-value row.

Examples

Rate a courseHover to preview, click to set. From the keyboard, Tab to the stars and use the arrow keys.
How was Database Systems?
<span class="field__label" id="course-rating">How was Database Systems?</span>
<div class="stars" role="radiogroup" aria-labelledby="course-rating">
  <button type="button" class="star on" role="radio" aria-checked="false" tabindex="-1" aria-label="1 star"><span class="ic" aria-hidden="true">star</span></button>
  <button type="button" class="star on" role="radio" aria-checked="false" tabindex="-1" aria-label="2 stars"><span class="ic" aria-hidden="true">star</span></button>
  <button type="button" class="star on" role="radio" aria-checked="true" tabindex="0" aria-label="3 stars"><span class="ic" aria-hidden="true">star</span></button>
  <button type="button" class="star" role="radio" aria-checked="false" tabindex="-1" aria-label="4 stars"><span class="ic" aria-hidden="true">star</span></button>
  <button type="button" class="star" role="radio" aria-checked="false" tabindex="-1" aria-label="5 stars"><span class="ic" aria-hidden="true">star</span></button>
</div>
<!-- Your code: click sets .on up to the star and aria-checked on it; hover adds .preview; arrow keys move. -->
Read-only averageDisplay only: spans, not buttons, and one name for the whole row.
4.2 from 318 students
<div class="docs-row" style="gap: 8px;">
  <span class="stars" role="img" aria-label="4 of 5 stars"><span class="star on"><span class="ic" aria-hidden="true">star</span></span><span class="star on"><span class="ic" aria-hidden="true">star</span></span><span class="star on"><span class="ic" aria-hidden="true">star</span></span><span class="star on"><span class="ic" aria-hidden="true">star</span></span><span class="star"><span class="ic" aria-hidden="true">star</span></span></span>
  <span class="field__help">4.2 from 318 students</span>
</div>

Anatomy

PartWhat it is
.starsRequired. Inline row of five, 2 px apart. role="radiogroup" with an aria-label for input; role="img" with an aria-label ("4 of 5 stars") for display.
button.star[role=radio]Required for input. 40 px target with a filled star icon, aria-checked and a name ("4 stars").
.onOn each star up to the chosen score: warning color.
.previewOn stars up to the hovered one while hovering: lighter warning color.

States

StateHow
.onChosen stars, in --warning.
.previewHover preview, --warning at 55 %.
:activeThe pressed star sinks to 0.85 and springs back.
focus-visibleThe system focus ring on the focused star.

Motion and microinteractions

  • Color changes in --d-fast (160 ms) on --ease-standard, so sweeping across the stars feels continuous.
  • Press: scale(0.85), back on --spring-snappy (360 ms).
  • Reduced motion: transitions become 120 ms linear.

Accessibility

  • For input it is a radio group: role="radiogroup" with a label, each star role="radio" with aria-checked and a name ("3 stars").
  • Roving focus: only the checked star (or the first when none) has tabindex="0"; arrow keys move and select. The system has no script for this; the demo shows the lines needed.
  • For display, one role="img" with an aria-label ("4 of 5 stars") and plain spans; never five separate announcements.
  • Pair the stars with the number as text when the average matters (4.2).

Do and don't

Do

  • Ask one clear question above the stars.
  • Let people change their rating; thank them in place, not with a dialog.

Don't

  • Use half stars for input.
  • Use stars for a yes or no question.

Behavior and code

Plain HTML. None in the system. Set .on and aria-checked on click, .preview on hover, and handle arrow keys in your code.