# Rating

A star rating you can choose with a mouse, touch or arrow keys.

- Family: Forms, imported from `mizu-ui` or `mizu-ui/forms`
- Docs: https://mizu.user64bit.world/components/rating
- Source: https://github.com/0xuser64bit/mizu/blob/main/packages/mizu/src/forms/Selection.tsx

## Usage

```tsx
"use client";

import { useState } from "react";
import { Rating } from "mizu-ui";

export function Example() {
  const [value, setValue] = useState(3);
  return (
    <Rating
      label="How useful was this?"
      value={value}
      onValueChange={setValue}
    />
  );
}
```

## Copy it with the shadcn CLI

```sh
npx shadcn@latest init 0xuser64bit/mizu/preset # once, where there is no components.json
npx shadcn@latest add 0xuser64bit/mizu/rating
```

## Props

- `value / onValueChange`: `number / function`. Controlled selected score.
- `max`: `number` (default `5`). One to ten stars.

## Accessibility

Native radio choices announce each score and support arrow keys. Decoration is hidden from readers.

## Motion

CSS transitions explain state changes. Reduced motion removes travel.
