Rating API
Demos
For examples and details on the usage of this React component, visit the component demo pages:
Import
import Rating from '@mui/material/Rating';
// or
import { Rating } from '@mui/material';Props
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:
objectAccepts 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:
funcDefault:
function defaultLabelText(value) {
return `${value} Star${value !== 1 ? 's' : ''}`;
}Signature:
function(value: number) => stringvalueThe rating label's value to format.
The component containing the icon.
Type:
elementTypeDefault:
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:
stringCallback fired when the value changes.
Type:
funcSignature:
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:
funcSignature:
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 | objectref is forwarded to the root element.Theme default props
You can use MuiRating to change the default props of this component with the theme.
CSS
The following class names are useful for styling with CSS (the state classes are marked).
To learn more, visit the component customization page.
Styles applied to the label of the "no value" input when it is active.
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.