# RatingGroup (@limerdev/zest) A rating out of `max` stars (5 by default), announced as a slider: `` (`bind:value`, `allowHalf`, `readonly`, `name`) draws its stars when it has no children; for custom ones, render `RatingGroup.Item`s (`index`) from the `children` snippet's `items`; each item's own `children` snippet gets its `state`. Arrow keys change the rating, Home and End go to the ends. Inside a `Field` it is named by `Field.Label`; outside one, give it `aria-label`. - Category: Data input - Import: `import { RatingGroup } from '@limerdev/zest'` - Bits UI: `RatingGroup`, https://bits-ui.com/docs/components/rating-group - Exports: `RatingGroup.Root`, `RatingGroup.Item` - Use for: Rating something: feedback on a delivery, how a sprint went. - Don't: A choice between named options: use `RadioGroup`. Showing an average read-only without the number: show the number too. ```svelte How did the sprint go? ``` Props of `RatingGroup.Root`: - `allowHalf` (`boolean`, default `false`): Whether to allow half-star ratings. - `aria-valuetext` (`RatingGroupAriaValuetext`, default `((value: number, max: number) => `${value} out of ${max}`)`): An extended `aria-valuetext` property to use for the rating group. Can either be a string, or a function that receives the current value and max value and returns a string. - `disabled` (`boolean`, default `false`): Whether the rating group is disabled. - `hoverPreview` (`boolean`, default `true`): Whether to show a preview when hovering over rating items. Touch events are ignored to prevent accidental previews. - `max` (`number`, default `5`): The maximum rating value (number of items). - `min` (`number`, default `0`): The minimum rating value. - `name` (`string`, default `undefined`): The name to apply to the rating group's input element for form submission. If not provided, a hidden input will not be rendered and the rating group will not be part of a form. - `onValueChange` (`OnChangeFn`): The callback to call when the rating value changes. - `orientation` (`"horizontal" | "vertical"`, default `"horizontal"`): The orientation of the rating group. Used to determine how keyboard interactions work. - `readonly` (`boolean`, default `false`): Whether the rating group is readonly. - `required` (`boolean`, default `false`): Whether the rating group is required for form submission. If `true`, ensure you provide a `name` prop so the hidden input is rendered. - `value` (`number`, default `0`, bindable): The current rating value. Props of `RatingGroup.Item`: - `disabled` (`null | false | true`, default `false`): Whether the rating item is disabled. - `index` (`number`, required): The index of the rating item (0-based index). Example: Basic In a Field the label names the rating. allowHalf allows half stars; readonly shows a rating that can't change. ```svelte
How did the sprint go? {rating} of 5 Average this quarter 3.5 of 5
```