Rating
Star rating input — interactive or read-only, with optional half stars.
Import
tsx
import { Rating } from "@cronus-ui/ui";
bash
npx cronus-ui add rating
Examples
.cronus
The same component declared in Cronus. Emitted at build time from the audit fixtures — the kernel renders it as HTML with no React.
default.cronus
app "audit-fixtures" {
port 5176
}
style {
preset aurora
theme dark
}
component RatingDefault layout:inline style:rating {
value:3
aria-label:"Quality"
label "Quality"
}
page "/audit/rating/default" type:custom {
use RatingDefault
}
API Reference
Generated from the component's exported types.
RatingProps
Extends VariantProps<typeof ratingVariants>
| Prop | Type | Default | Description |
|---|---|---|---|
value | number | — | Controlled value. Pair with `onValueChange`. |
defaultValue | number | 0 | Initial value for uncontrolled usage. Defaults to `0`. |
onValueChange | (value: number) => void | — | Called with the new value whenever the rating changes. |
max | number | 5 | Number of stars. Defaults to `5`. |
readOnly | boolean | false | Renders display-only with no interaction. Defaults to `false`. |
allowHalf | boolean | false | Allows half-star (0.5) granularity. Defaults to `false`. |
size | "sm" | "md" | "lg" | "md" | Star size preset. Defaults to `"md"`. |
aria-label | string | — | Accessible name for the rating when there is no visible label. |
aria-labelledby | string | — | ID of an element labelling the rating. |
className | string | — | Extra classes for the wrapper element. |
asChild | boolean | — | Render as the child element via Slot. |
children | ReactNode | — | Contents of the component. |