Rating
UI SDK Rating styled as stars that fill to the score: half stars, averages that fill part of a star, a pointer preview, sizes and 44px stars on touch screens.
Example
rating-demo.tsxCopy code
Installation
Copy code
npm packages
lucide-reactUsage
ImportCopy code
API reference
Rating
| Prop | Type | Default |
|---|---|---|
size | "sm" | "md" | "lg" | "md" |
iconThe icon of each star, drawn twice: an outline, and a filled copy clipped to how much of the star is covered. | ComponentType<SVGProps<SVGSVGElement>> | StarIcon |
Also takes every prop of UI SDK Rating.
RatingItem
| Prop | Type | Default |
|---|---|---|
icon | ComponentType<SVGProps<SVGSVGElement>> | StarIcon |
Also takes every prop of UI SDK RatingItem.
Other exports
createRatingControllertype RatingItemPropstype RatingPropstype RatingSizetype RatingControllertype RatingItemStatetype RatingStatetype RatingValueChangeReasonAccessibility
- A radio group: arrow keys change the score, Space checks the focused star; each score is a radio named like "3 stars".
- Stars fill in the warning colour over an input-strong outline, so the score shows by shape and fill, not hue alone.
- Read-only, it is one image named by getValueLabel.
Agent actions
Agents find it by its label and set a score with setValue.
Runs agent.snapshot() from @ui-sdk/react/agent on the live preview above.