diff --git a/docs/src/pages/components/rating/CustomizedRatings.js b/docs/src/pages/components/rating/CustomizedRatings.js
index 418397e0668a99..aacf69d6c1603f 100644
--- a/docs/src/pages/components/rating/CustomizedRatings.js
+++ b/docs/src/pages/components/rating/CustomizedRatings.js
@@ -1,8 +1,14 @@
import React from 'react';
+import PropTypes from 'prop-types';
import { withStyles } from '@material-ui/core/styles';
import Rating from '@material-ui/lab/Rating';
import StarBorderIcon from '@material-ui/icons/StarBorder';
import FavoriteIcon from '@material-ui/icons/Favorite';
+import SentimentVeryDissatisfiedIcon from '@material-ui/icons/SentimentVeryDissatisfied';
+import SentimentDissatisfiedIcon from '@material-ui/icons/SentimentDissatisfied';
+import SentimentSatisfiedIcon from '@material-ui/icons/SentimentSatisfied';
+import SentimentSatisfiedAltIcon from '@material-ui/icons/SentimentSatisfiedAltOutlined';
+import SentimentVerySatisfiedIcon from '@material-ui/icons/SentimentVerySatisfied';
import Typography from '@material-ui/core/Typography';
import Box from '@material-ui/core/Box';
@@ -15,10 +21,38 @@ const StyledRating = withStyles({
},
})(Rating);
-function getLabelText(value) {
- return `${value} Heart${value !== 1 ? 's' : ''}`;
+const customIcons = {
+ 1: {
+ icon: ,
+ label: 'Very Dissatisfied',
+ },
+ 2: {
+ icon: ,
+ label: 'Dissatisfied',
+ },
+ 3: {
+ icon: ,
+ label: 'Neutral',
+ },
+ 4: {
+ icon: ,
+ label: 'Satisfied',
+ },
+ 5: {
+ icon: ,
+ label: 'Very Satisfied',
+ },
+};
+
+function IconContainer(props) {
+ const { value, ...other } = props;
+ return {customIcons[value].icon};
}
+IconContainer.propTypes = {
+ value: PropTypes.number.isRequired,
+};
+
export default function CustomizedRatings() {
return (
@@ -36,7 +70,7 @@ export default function CustomizedRatings() {
`${value} Heart${value !== 1 ? 's' : ''}`}
precision={0.5}
icon={}
/>
@@ -45,6 +79,15 @@ export default function CustomizedRatings() {
10 stars
+
+ Custom icon set
+ customIcons[value].label}
+ IconContainerComponent={IconContainer}
+ />
+
);
}
diff --git a/docs/src/pages/components/rating/CustomizedRatings.tsx b/docs/src/pages/components/rating/CustomizedRatings.tsx
index 28dbf1bc8c0891..36cc00b7982205 100644
--- a/docs/src/pages/components/rating/CustomizedRatings.tsx
+++ b/docs/src/pages/components/rating/CustomizedRatings.tsx
@@ -1,8 +1,13 @@
import React from 'react';
import { withStyles } from '@material-ui/core/styles';
-import Rating from '@material-ui/lab/Rating';
+import Rating, { IconContainerProps } from '@material-ui/lab/Rating';
import StarBorderIcon from '@material-ui/icons/StarBorder';
import FavoriteIcon from '@material-ui/icons/Favorite';
+import SentimentVeryDissatisfiedIcon from '@material-ui/icons/SentimentVeryDissatisfied';
+import SentimentDissatisfiedIcon from '@material-ui/icons/SentimentDissatisfied';
+import SentimentSatisfiedIcon from '@material-ui/icons/SentimentSatisfied';
+import SentimentSatisfiedAltIcon from '@material-ui/icons/SentimentSatisfiedAltOutlined';
+import SentimentVerySatisfiedIcon from '@material-ui/icons/SentimentVerySatisfied';
import Typography from '@material-ui/core/Typography';
import Box from '@material-ui/core/Box';
@@ -15,8 +20,32 @@ const StyledRating = withStyles({
},
})(Rating);
-function getLabelText(value: number) {
- return `${value} Heart${value !== 1 ? 's' : ''}`;
+const customIcons: { [index: string]: { icon: React.ReactElement; label: string } } = {
+ 1: {
+ icon: ,
+ label: 'Very Dissatisfied',
+ },
+ 2: {
+ icon: ,
+ label: 'Dissatisfied',
+ },
+ 3: {
+ icon: ,
+ label: 'Neutral',
+ },
+ 4: {
+ icon: ,
+ label: 'Satisfied',
+ },
+ 5: {
+ icon: ,
+ label: 'Very Satisfied',
+ },
+};
+
+function IconContainer(props: IconContainerProps) {
+ const { value, ...other } = props;
+ return {customIcons[value].icon};
}
export default function CustomizedRatings() {
@@ -36,7 +65,7 @@ export default function CustomizedRatings() {
`${value} Heart${value !== 1 ? 's' : ''}`}
precision={0.5}
icon={}
/>
@@ -45,6 +74,15 @@ export default function CustomizedRatings() {
10 stars
+
+ Custom icon set
+ customIcons[value].label}
+ IconContainerComponent={IconContainer}
+ />
+
);
}