Rating

A row of star buttons.

Colors (read-only)

Sizes

Real use · rate this product

You rated this 3 of 5 stars

Using Rating

Silica ships one design system through three paths. They share a class vocabulary but are not interchangeable — pick the one that matches what you are building.

Plain HTML — CSS classes

The Tailwind v4 plugin. Works in any framework or none — Rails, Django, PHP, Go, a static file. This path ships no JavaScript, so Rating is styled but inert: its behavior comes from rating. For that behavior with no framework, use the node-tree path below.

/* in your CSS */
@import "tailwindcss";
@plugin "@wizeworks/silicaui";

Root class rating, with 15 modifiers:

  • .rating
  • .rating-accent
  • .rating-error
  • .rating-info
  • .rating-item
  • .rating-lg
  • .rating-md
  • .rating-neutral
  • .rating-primary
  • .rating-readonly
  • .rating-secondary
  • .rating-sm
  • .rating-success
  • .rating-warning
  • .rating-xl
  • .rating-xs

React

Typed components over those same classes, with behavior and accessibility from Base UI.

npm i @wizeworks/silicaui-react
import { Rating } from "@wizeworks/silicaui-react";

Props

PropTypeRequiredDescription
valuenumbernoControlled value (number of filled stars).
defaultValuenumbernoInitial value when uncontrolled.
onValueChange(value: number) => voidnoCalled with the new rating whenever it changes.
onChange(value: number) => voidno@deprecated Use onValueChange. onChange is reserved for the native DOM handler on components that wrap a real form element; still honored here so this isn't a breaking change.
maxnumbernoNumber of stars. Default 5.
colorRatingColornoAccent color for filled stars. Default warning (gold).
sizeRatingSizenoStar size.
readOnlybooleannoRender non-interactive.
iconReact.ReactNodenoCustom star icon (defaults to a filled star).
labelstringnoAccessible label for the group.

Source of the demo above

The exact file that renders the examples above, so it can never drift from them. It imports a few of this site’s own layout helpers (../lib/…), so read it for the component calls rather than copying it whole.

Show source
import { useState } from "react";
import { Rating } from "@wizeworks/silicaui-react";
import { Section, Row, LabeledRow } from "../lib/Section";
import { COLORS, SIZES } from "../lib/data";

export function RatingDemo() {
    const [stars, setStars] = useState(3);

    return (
        <>
            <Section title="Colors (read-only)">
                <Row>
                    {COLORS.slice(0, 6).map((color) => (
                        <Rating key={color} color={color} defaultValue={4} readOnly />
                    ))}
                </Row>
            </Section>

            <Section title="Sizes">
                <div className="flex flex-col gap-2">
                    {SIZES.map((size) => (
                        <Rating key={size} color="warning" size={size} defaultValue={3} readOnly />
                    ))}
                </div>
            </Section>

            <Section title="Real use · rate this product">
                <LabeledRow label={`You rated this ${stars} of 5 stars`}>
                    <Rating color="warning" value={stars} onValueChange={setStars} />
                </LabeledRow>
            </Section>
        </>
    );
}

Vanilla — node tree to HTML

rating — not Base UI-backed in React either (plain JSX-set data-filled), so this ports near 1:1. Build a node tree, project it with toHtml(), and let the zero-dependency runtime hydrate it. This is the path for generated or user-authored documents — a site builder, CMS output, a static export.

npm i @wizeworks/silicaui-html @wizeworks/silicaui-behaviors
import { atom, toHtml } from "@wizeworks/silicaui-html";

const node = atom("Rating", "rating", { /* props */ });
const markup = toHtml(node);

Styling on this path is the class string in the second argument — the same classes as the Plain HTML section above. There is no color prop here; write "rating rating-primary" rather than passing a colour as a prop.

Takes children
no
Hydrated by
rating

Load @wizeworks/silicaui-behaviors on the page or this markup renders correctly and does nothing.

The full API for Rating, on every path, is available through the Silica MCP server.