RatingField
Displays a numeric rating as a row of filled / half / outlined star icons.
Installation
pnpm dlx shadcn@latest add @shadmin/rating-fieldUsage
import { RatingField } from '@/components/admin';
<RatingField source="rating" />
<RatingField source="rating" max={10} allowHalf />
<RatingField source="rating" countSource="reviewCount" empty="No ratings yet" />Props
| Prop | Required | Type | Default | Description |
|---|---|---|---|---|
source | Required | string | - | Record field to read |
max | Optional | number | 5 | Total stars rendered |
allowHalf | Optional | boolean | false | Render half-stars for fractional values |
countSource | Optional | string | - | Sibling field rendered as (N) next to the stars |
empty | Optional | ReactNode | - | Fallback when value is null/undefined |
className | Optional | string | - | CSS class on the wrapping <span> |
defaultValue | Optional | number | - | Default when no record value exists |
record | Optional | RecordType | - | Record to read instead of useRecordContext() |
max
Defaults to 5. Set to 10 for 10-star scales.
allowHalf
When true, values like 3.5 render the third and fourth stars as one filled
star plus one half-filled star. When false, fractional values are rounded
toward zero.
countSource
Reads a sibling field from the same record and renders it in parentheses to the right of the stars.