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.
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' : ''}`;
}
Signature:
function(value: number) => string
value
The 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
Signature:
function(event: React.SyntheticEvent, value: number | null) => void
event
The event source of the callback.value
The new value.
Callback function that is fired when the hover state changes.
Type:
func
Signature:
function(event: React.SyntheticEvent, value: number) => void
event
The event source of the callback.value
The new value.
The system prop that allows defining system overrides as well as additional CSS styles.
Type:
Array<func | object | bool> | func | object
ref
is forwarded to the root element.Theme default props
You can useMuiRating
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
styleOverrides
property in a custom theme.