// Generated by scripts/generate-showcase.mjs. Do not edit directly. page RatingDetail { layout = "showcase" state playground_size = ctx.url.searchParams.get("pg_size") ?? "default" state playground_color = ctx.url.searchParams.get("pg_color") ?? "primary" state playground_title = ctx.url.searchParams.get("pg_title") ?? "How was your experience?" state playground_description = ctx.url.searchParams.get("pg_description") ?? "" state playground_items = JSON.parse(ctx.url.searchParams.get("pg_items") ?? "[]") state playground_variant = ctx.url.searchParams.get("pg_variant") ?? "default" state playground_value = Number(ctx.url.searchParams.get("pg_value") ?? "4") state playground_max = Number(ctx.url.searchParams.get("pg_max") ?? "5") state playground_step = Number(ctx.url.searchParams.get("pg_step") ?? "1") state playground_readonly = (ctx.url.searchParams.get("pg_readonly") ?? "false") === "true" state playground_disabled = (ctx.url.searchParams.get("pg_disabled") ?? "false") === "true" state playground_class = ctx.url.searchParams.get("pg_class") ?? "" seo { title = "Rating" description = "Theme-aware, responsive rating component." } view {
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
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
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
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
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
} }