Examples
Selectable rating
A named radio group supports keyboard selection.
Product rating
import { Rate } from "@phuctech/ui/components/rate";
export function Example() {
return <Rate label="Product rating" defaultValue={4} />;
}
Read-only rating
Show a saved score without making it interactive.
Read-only customer rating
import { Rate } from "@phuctech/ui/components/rate";
export function Example() {
return <Rate label="Customer rating" value={4} readOnly />;
}
Disabled rating
Keep the rating control visible while unavailable.
Disabled rating
import { Rate } from "@phuctech/ui/components/rate";
export function Example() {
return <Rate label="Not yet rated" disabled />;
}
Try the rating
Change the score and maximum rating.
Rating property playground
import { Rate } from "@phuctech/ui/components/rate";
export function Example() {
return <Rate label="Product rating" value={3} max={5} />;
}
Usage
import { Rate } from "@phuctech/ui/components/rate";
<Rate label="Product rating" defaultValue={4} onValueChange={setRating} />Rate supports integer scores from 1 through max. The default maximum is five and is clamped to the supported range of one through ten. It intentionally does not implement half steps or rating business rules.
API
Accessibility
Rate uses the shared RadioGroup for one-tab-stop keyboard navigation and arrow-key choice. Every star has an explicit score label. The visible criterion names the rating, and the current score is announced politely.
Related
- RadioGroup supports labeled non-rating choices.
- InputNumber accepts an exact numeric score.