Files
react-test/docs/data/material/components/rating/CustomizedRating.tsx

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

34 lines
1.1 KiB
TypeScript
Raw Normal View History

2025-12-12 14:26:25 +09:00
import { styled } from '@mui/material/styles';
import Box from '@mui/material/Box';
import Rating from '@mui/material/Rating';
import FavoriteIcon from '@mui/icons-material/Favorite';
import FavoriteBorderIcon from '@mui/icons-material/FavoriteBorder';
import Typography from '@mui/material/Typography';
const StyledRating = styled(Rating)({
'& .MuiRating-iconFilled': {
color: '#ff6d75',
},
'& .MuiRating-iconHover': {
color: '#ff3d47',
},
});
export default function CustomizedRating() {
return (
<Box sx={{ '& > legend': { mt: 2 } }}>
<Typography component="legend">Custom icon and color</Typography>
<StyledRating
name="customized-color"
defaultValue={2}
getLabelText={(value: number) => `${value} Heart${value !== 1 ? 's' : ''}`}
precision={0.5}
icon={<FavoriteIcon fontSize="inherit" />}
emptyIcon={<FavoriteBorderIcon fontSize="inherit" />}
/>
<Typography component="legend">10 stars</Typography>
<Rating name="customized-10" defaultValue={2} max={10} />
</Box>
);
}