# Star rating input

A star rating you set, read back or lock, in two sizes.

Section: Components / Inputs
Page: https://ui.heyramzi.com/components/star-rating-input
Import path: `@heyramzi/ui/components/star-rating-input`

## Import

```ts
import { StarRatingInput } from "@heyramzi/ui/components/star-rating-input";
```

## Demo

```svelte
<script lang="ts">
	import { StarRatingInput } from "@heyramzi/ui/components/star-rating-input";

	const labels = ["Poor", "Fair", "Good", "Very good", "Excellent"] as const;

	let rating = $state(0);
	let small = $state(4);
</script>

<div class="flex flex-col items-start gap-6">
	<StarRatingInput bind:value={rating} size="lg" {labels} showLabel ariaLabel="Rate the delivery" />
	<StarRatingInput bind:value={small} />
	<StarRatingInput value={3} readonly ariaLabel="Last delivery" />
	<StarRatingInput value={2} disabled />
</div>
```

## API

| Prop | Type | Default | Notes |
| --- | --- | --- | --- |
| `value` | `number` | `0` | bindable. Current rating value (0 = unrated). |
| `max` | `number` | `5` | Maximum rating. Defaults to 5. |
| `size` | `"sm"` \| `"lg"` | `"sm"` | Visual size of each star. `sm` reads back, `lg` asks. |
| `readonly` | `boolean` | `false` | Render as static display, no hover or click. |
| `disabled` | `boolean` | `false` | Disable interaction. |
| `name` | `string` |  | Form field name for native submission. When set, a hidden input is rendered. |
| `ariaLabel` | `string` |  | What is rated, like "Rate the delivery". The value is added for a screen reader. |
| `labels` | `readonly string[]` |  | Per-step descriptive labels (length must equal max). |
| `showLabel` | `boolean` | `false` | Show the label of the currently hovered/selected step beside the stars. |
| `class` | `string` |  |  |
| `onValueChange` | `(value: number) => void` |  | Called with the new rating after a pick. |
