Skip to content
v0.9.1
Forms

Rating

Stars for reviews and feedback. The stars you click are real radio buttons, so arrow keys work and forms get the value. A read-only score can show any fraction, like 4.3. The stars are Moey Icons star and star-filled.

Basic

A fieldset.rating with one label.rating-star per star. Every input shares a name and has its own aria-label.

Rate this course
<fieldset class="rating">
  <legend class="visually-hidden">Rate this course</legend>
  <label class="rating-star"><input type="radio" name="rt-course" value="1" aria-label="1 star"></label>
  <label class="rating-star"><input type="radio" name="rt-course" value="2" aria-label="2 stars"></label>
  <label class="rating-star"><input type="radio" name="rt-course" value="3" aria-label="3 stars" checked></label>
  <label class="rating-star"><input type="radio" name="rt-course" value="4" aria-label="4 stars"></label>
  <label class="rating-star"><input type="radio" name="rt-course" value="5" aria-label="5 stars"></label>
</fieldset>

With a label

Add data-momo-rating-clear to let a second click on the picked star clear it (no rating).

How was your support call?

Click the same star again to clear it.

<div class="form-field">
  <span class="form-label" id="rt-q">How was your support call?</span>
  <fieldset class="rating rating-lg" aria-labelledby="rt-q" data-momo-rating-clear>
    <label class="rating-star"><input type="radio" name="rt-call" value="1" aria-label="1 star, bad"></label>
    <label class="rating-star"><input type="radio" name="rt-call" value="2" aria-label="2 stars"></label>
    <label class="rating-star"><input type="radio" name="rt-call" value="3" aria-label="3 stars"></label>
    <label class="rating-star"><input type="radio" name="rt-call" value="4" aria-label="4 stars"></label>
    <label class="rating-star"><input type="radio" name="rt-call" value="5" aria-label="5 stars, great"></label>
  </fieldset>
  <p class="form-hint">Click the same star again to clear it.</p>
</div>

Read-only score

A .rating-static with data-value (and data-max, 5 by default). It fills any fraction and names itself for screen readers ("4.3 out of 5"). Put text next to it in a .rating-row.

4.3 (128 reviews)
<div class="rating-row">
  <span class="rating-static" data-value="4.3"></span>
  <span class="rating-text">4.3 <span class="rating-count">(128 reviews)</span></span>
</div>

Colors and sizes

Stars are yellow by default. .rating-<color> for any color, .rating-sm and .rating-lg for both kinds.

<div class="form-grid">
  <span class="rating-static rating-sm rating-pink" data-value="3.5"></span>
  <span class="rating-static rating-green" data-value="4"></span>
  <span class="rating-static rating-lg rating-violet" data-value="2.5"></span>
</div>

In a review card

ML Mara Lindqvist2 days ago

Setup took ten minutes and the team picked it up on day one.

<article class="card card-body">
  <div class="person">
    <span class="avatar bg-cyan" role="img" aria-label="Mara Lindqvist">ML</span>
    <span class="person-text"><span class="person-name">Mara Lindqvist</span><span class="person-sub">2 days ago</span></span>
  </div>
  <span class="rating-static rating-sm" data-value="5"></span>
  <p>Setup took ten minutes and the team picked it up on day one.</p>
</article>

Disabled and read-only

disabled on the fieldset grays it out. .rating-readonly keeps the colors but ignores clicks (use .rating-static when it never changes).

Disabled rating
<fieldset class="rating rating-sm" disabled>
  <legend class="visually-hidden">Disabled rating</legend>
  <label class="rating-star"><input type="radio" name="rt-off" value="1" aria-label="1 star" checked></label>
  <label class="rating-star"><input type="radio" name="rt-off" value="2" aria-label="2 stars"></label>
  <label class="rating-star"><input type="radio" name="rt-off" value="3" aria-label="3 stars"></label>
  <label class="rating-star"><input type="radio" name="rt-off" value="4" aria-label="4 stars"></label>
  <label class="rating-star"><input type="radio" name="rt-off" value="5" aria-label="5 stars"></label>
</fieldset>

JavaScript

Read the value like any radio group: form.elements['rt-course'].value, and listen to change. If you change data-value on a score, call Momo.slider.refresh(el).

Variables

VariableDefault
--rating-coloryellow
--rating-emptysurface
--rating-size1.75rem (score: 1.25rem)

Start

OverviewStart Getting startedStart CustomizeStart

Guides

AccessibilityGuides BreakpointsGuides ChangelogGuides Customize componentsGuides JavaScriptGuides MotionGuides OptimizeGuides PhonesGuides RebootGuides Right-to-left (RTL)Guides Stacking orderGuides Using Momo with AIGuides

Foundations

ColorsFoundations TypographyFoundations ProseFoundations Images & figuresFoundations CodeFoundations Lines & shadowsFoundations Dark modeFoundations

Forms

Checkbox & switchForms ComboboxForms Date pickerForms Date rangeForms Fields & labelsForms File uploadForms Floating labelsForms Number stepperForms PasswordForms PIN codeForms RatingForms SelectForms SliderForms Tag inputForms Time pickerForms ValidationForms

Components

AccordionComponents Alert & bannerComponents AvatarComponents BadgeComponents BreadcrumbComponents ButtonComponents Button groupComponents CalendarComponents CardComponents CarouselComponents ChartsComponents ChipsComponents CollapseComponents Command paletteComponents CommentsComponents Confirm dialogsComponents Cookie bannerComponents Data tableComponents Description listComponents Dialog & toastComponents DividerComponents DrawerComponents Dropdown menuComponents Empty stateComponents File managerComponents Filter & sortComponents Gallery & lightboxComponents Inbox & chatComponents Infinite scrollComponents KanbanComponents Keyboard shortcutsComponents List groupComponents MarqueeComponents Media objectComponents Nav overflowComponents Notification centerComponents PaginationComponents ProgressComponents Pull to refreshComponents SkeletonComponents SortableComponents SpinnerComponents Split viewComponents Stat cardComponents Steps & wizardComponents Swipe actionsComponents TableComponents TabsComponents TimelineComponents TogglerComponents Tooltip & popoverComponents TourComponents Tree viewComponents VideoComponents WhiteboardComponents

Layout

Announcement barLayout App shellLayout Back to topLayout Container & sectionLayout ExamplesLayout FooterLayout HeroLayout JumbotronLayout Mega menuLayout NavbarLayout Site sidebarLayout

Sections

Bento gridSections Blog cardsSections Call to actionSections Contact & newsletterSections FAQSections FeaturesSections Logo cloudSections PricingSections TeamSections TestimonialsSections

Utilities

OverviewUtilities State variantsUtilities Display & flexUtilities Grid & gapUtilities SpacingUtilities SizingUtilities TextUtilities Links & color strengthUtilities Position & overflowUtilities BackgroundsUtilities Borders & effectsUtilities Transforms & filtersUtilities InteractionsUtilities

Helpers

Fixed, sticky & frostedHelpers Hover & focusHelpers Hover revealHelpers Icon linkHelpers PrintHelpers Relative timeHelpers Screen reader textHelpers Scroll inHelpers ScrollspyHelpers Share buttonHelpers Skip linkHelpers StacksHelpers Stretched linkHelpers Theme toggleHelpers Truncated textHelpers

Page patterns

404 pagePage patterns Coming soonPage patterns Login & registerPage patterns SettingsPage patterns ProfilePage patterns CRM contactsPage patterns ProjectsPage patterns File manager pagePage patterns Billing & plansPage patterns Help centerPage patterns Mobile app screensPage patterns
↑ ↓ moveEnter openEsc close