WRNexus UI
Base component

Rating

Theme-aware, responsive rating component.

12 props1 slots2 outputsTheme readyResponsive
Interactive playground

Configure Rating

Change any prop and inspect the server-rendered component immediately.

Live preview
How was your experience?
4 / 5
Component code
page RatingExample {
  state items = []
  view {
    <Rating
      title="How was your experience?"
      items="{items}"
      value="4"
    />
  }
}
Event outputInteract with the preview to inspect the typed payload.
Component props12 controls
Live examples

Designed for real product surfaces

Compare configurations and resize the browser to check responsive behavior.

Recommended

Whole stars

Choose a rating from zero to five with step 1.

01
Live preview
Rate your experience
3 / 5
Component usage.wrn
page RatingExample {
  state items = []
  view {
    <Rating
      title="Rate your experience"
      items="{items}"
      value="3"
    />
  }
}
Compact

Half stars

Click a half star or use the precise slider and arrow keys.

02
Live preview
Half-star rating
3.5 / 5
Component usage.wrn
page RatingExample {
  state items = []
  view {
    <Rating
      title="Half-star rating"
      items="{items}"
      value="3.5"
      step="0.5"
    />
  }
}
Advanced

Fine increments

Use increments of 0.2 for a more precise rating.

03
Live preview
Detailed score
4.2 / 5
Component usage.wrn
page RatingExample {
  state items = []
  view {
    <Rating
      title="Detailed score"
      items="{items}"
      value="4.2"
      step="0.2"
      readonly="true"
    />
  }
}
Component outputs

Receive every typed component output

Use declarative output handlers in .wrn files or register a direct output handler from JavaScript. The canonical API exposes payload and does not require event.detail.

@inputFires as the editable value changes.
@changeFires when the component's committed value or selection changes.
Declarative handlers.wrn
<Rating
  @input='console.log(payload)'
  @change='console.log(payload)'
/>
Direct output handlers.js
import { registerOutputHandler } from "@wrnexus/csr/outputs"

const component = document.querySelector("[data-ui-component=\"Rating\"], [data-component=\"Rating\"]")

if (component) registerOutputHandler(component, "input", (payload) => {
  console.log("input", payload)
})

if (component) registerOutputHandler(component, "change", (payload) => {
  console.log("change", payload)
})
Component API

Props and configuration

All content and behavior shown above is supplied through these props and slots.

PropTypeDefaultRequired
sizestring"default"No
colorstring"primary"No
titlestring"Rating"No
descriptionstring""No
itemsunknown[][]No
variantstring"default"No
valuenumber0No
maxnumber5No
stepnumber1No
readonlybooleanfalseNo
disabledbooleanfalseNo
classstring""No