Rate
Documentation and examples for the Rate component.
When To Use
- Show evaluation.
- A quick rating operation on something.
Example Usage
astro
---
import Rate from '@/components/data-entry/Rate.astro';
---
<Rate value={4} max={5} /> Half-Stars
Enable half-star precision with the allowHalf prop.
astro
<Rate value={3.5} max={5} allowHalf={true} /> Colors and Icons
Customize the appearance with color and icon props.
astro
<Rate value={4} max={5} color="yellow" />
<Rate value={3} max={5} color="red" icon="Heart" />
<Rate value={5} max={5} color="green" icon="ThumbsUp" /> Sizes
astro
<Rate value={3} max={5} size="sm" />
<Rate value={3} max={5} size="md" />
<Rate value={3} max={5} size="lg" /> API
| Property | Description | Type | Default |
|---|---|---|---|
| value | Current value of the rating | number | 0 |
| max | Maximum rating value | number | 5 |
| readonly | If true, the rating cannot be modified | boolean | false |
| name | Name attribute for the hidden input | string | 'rating' |
| icon | Icon to use for the rating | IconName | 'Star' |
| color | Color variant of the rating stars | 'default' | 'yellow' | 'orange' | 'red' | 'green' | 'blue' | 'purple' | 'default' |
| allowHalf | Whether to allow half-star ratings | boolean | false |
| size | Size of the rating icons | 'sm' | 'md' | 'lg' | 'md' |
| error | Indicates an error state or displays an error message | string | boolean | |
| success | Indicates a success state or displays a success message | string | boolean | |
| disabled | Disables the component | boolean | false |