Rating API
API reference docs for the React Rating component. Learn about the props, CSS, and other APIs of this exported module.
Component demos
Import
import Rating from '@mui/material/Rating';
// or
import { Rating } from '@mui/material';Props of the native component are also available.
Override or extend the styles applied to the component.
See CSS API below for more details.
Type:object
Accepts a function which returns a string value that provides a user-friendly name for the current value of the rating. This is important for screen reader users.
For localization purposes, you can use the provided translations.
Type:func
Default:function defaultLabelText(value) {
return `${value} Star${value !== 1 ? 's' : ''}`;
}
function(value: number) => stringvalueThe rating label's value to format.
The component containing the icon.
Type:elementType
Default:function IconContainer(props) {
const { value, ...other } = props;
return <span {...other} />;
}
The name attribute of the radio input elements. This input name should be unique within the page. Being unique within a form is insufficient since the name is used to generated IDs.
Type:string
Callback fired when the value changes.
Type:func
function(event: React.SyntheticEvent, value: number | null) => voideventThe event source of the callback.valueThe new value.
Callback function that is fired when the hover state changes.
Type:func
function(event: React.SyntheticEvent, value: number) => voideventThe event source of the callback.valueThe new value.
The system prop that allows defining system overrides as well as additional CSS styles.
See the `sx` page for more details.
Type:Array<func
| object
| bool>
| func
| object
ref is forwarded to the root element.Theme default props
You can use MuiRating to change the default props of this component with the theme.
These class names are useful for styling with CSS. They are applied to the component's slots when specific states are triggered.
Styles applied to the icon wrapping elements when decimals are necessary.
Rule name:decimal
Styles applied to the label of the "no value" input when it is active.
Rule name:labelEmptyValueActive
You can override the style of the component using one of these customization options:
- With a global class name.
- With a rule name as part of the component's
styleOverridesproperty in a custom theme.