---
title: Rating
description: "`Rating` is a component used to allow users to provide ratings."
links:
- source: https://github.com/yamada-ui/yamada-ui/tree/main/packages/react/src/components/rating
- storybook: https://yamada-ui.github.io/yamada-ui?path=/story/components-rating--basic
---
```tsx
```
## Usage
```tsx
import { Rating } from "@yamada-ui/react"
```
```tsx
import { Rating } from "@/components/ui"
```
```tsx
import { Rating } from "@workspaces/ui"
```
```tsx
```
### Change Size
```tsx
{(size) => }
```
### Change Color Scheme
```tsx
{(colorScheme) => (
)}
```
### Set Default Value
To set a default value, assign a number to `defaultValue`.
```tsx
```
### Change Number of Items
To change the number of items, assign a number to `count`.
```tsx
{(count) => }
```
### Set Decimals
To set decimals, assign a number to `fractions`.
For example, to set `0.25`, set `4`.
```tsx
{({ fractions, defaultValue }) => (
)}
```
### Highlight Selected Only
To highlight only the selected rating, set `highlightSelectedOnly` to `true`.
```tsx
```
### Change Color
To change the color, assign a string or function to `color`.
```tsx
const getColor = useCallback((value: number) => {
switch (value) {
case 1:
return "red.500"
case 2:
return "orange.500"
case 3:
return "yellow.500"
case 4:
return "green.500"
case 5:
return "blue.500"
default:
return undefined
}
}, [])
return (
)
```
### Disable
To disable, set `disabled` to `true`.
```tsx
```
### Read-Only
To make it read-only, set `readOnly` to `true`.
```tsx
```
### Customize Icons
To customize icons, assign `ReactNode` or a function to `emptyIcon` and `filledIcon`.
```tsx
const getColor = useCallback((value: number) => {
switch (value) {
case 1:
return "red.500"
case 2:
return "orange.500"
case 3:
return "yellow.500"
case 4:
return "green.500"
case 5:
return "blue.500"
default:
return undefined
}
}, [])
const getIcon = useCallback((value: number) => {
switch (value) {
case 1:
return
case 2:
return
case 3:
return
case 4:
return
case 5:
return
default:
return null
}
}, [])
return (
}
filledIcon={}
/>
)
```
### Control
```tsx
const [value, onChange] = useState(3)
return
```
## Props
| Prop | Default | Type | Description |
| ----------------------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------- |
| `as` | - | `As` | The HTML element to render. |
| `asChild` | - | `boolean` | Merges its props onto its immediate child. |
| `css` | - | `CSSObject \| CSSObject[]` | The CSS object. |
| `colorScheme` | - | `"amber" \| "black" \| "blackAlpha" \| "blue" \| "cyan" \| "danger" \| "emerald" \| "error" \| "flashy" \| "fuchsia" ...` | Set color scheme variables. |
| `size` | `"md"` | `"lg" \| "md" \| "sm" \| "xl" \| "xs"` | The size of the component. |
| `color` | - | `"-moz-initial" \| "ActiveBorder" \| "ActiveCaption" \| "aliceblue" \| "amber.100" \| "amber.200" \| "amber.300" \| "amber.400" \| "amber.50" \| "amber.500" ...` | The color of the filled icons. |
| `count` | `5` | `number` | Number of controls that should be rendered. |
| `defaultValue` | `0` | `number` | The initial value of the rating. |
| `disabled` | `false` | `boolean` | If `true`, the field will be disabled. |
| `emptyIcon` | - | `ReactNodeOrFunction` | The empty icon for the rating. |
| `filledIcon` | - | `ReactNodeOrFunction` | The filled icon for the rating. |
| `fractions` | `1` | `number` | Number of fractions each item can be divided into, |
| `groupProps` | - | `FunctionOrValue` | Props for the rating group. |
| `highlightSelectedOnly` | `false` | `boolean` | If `true`, only the selected icons will be filled. |
| `iconProps` | - | `FunctionOrValue` | Props for the rating item. |
| `id` | - | `string` | The top-level id string that will be applied to the rating. The index of the rating item will be appended to this top-level id. |
| `inputProps` | - | `FunctionOrValue>` | Props for the input element. |
| `invalid` | `false` | `boolean` | If `true`, the field will be invalid. |
| `itemProps` | - | `FunctionOrValue` | Props for the rating item. |
| `name` | - | `string` | The name of the input element. |
| `onChange` | - | `(value: number) => void` | The callback invoked when value state changes. |
| `onHover` | - | `(value: number) => void` | The callback invoked when hovering over the rating. |
| `readOnly` | `false` | `boolean` | If `true`, the field will be readonly. |
| `required` | `false` | `boolean` | If `true`, the field will be required. |
| `value` | - | `number` | The value of the rating. |
## Accessibility
Currently, this section is being updated due to the migration of v2.