/
githubmirror
/
material-ui
Обзор
Документация
Войти
/
githubmirror
/
material-ui
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
docs/data/material/components/rating/BasicRating.js
35 строк
1 KB
sai chand
[docs][material-ui][Rating] Add uncontrolled example to Basic Rating demo (#44386)
12 ноя 2024, 10:57
Не верифицирован
12 ноя 2024, 10:57
6d5876f
Код
Авторство
О чём код?
import * as React from 'react'; import Box from '@mui/material/Box'; import Rating from '@mui/material/Rating'; import Typography from '@mui/material/Typography'; export default function BasicRating() { const [value, setValue] = React.useState(2); return ( <Box sx={{ '& > legend': { mt: 2 } }}> <Typography component="legend">Controlled</Typography> <Rating name="simple-controlled" value={value} onChange={(event, newValue) => { setValue(newValue); }} /> <Typography component="legend">Uncontrolled</Typography> <Rating name="simple-uncontrolled" onChange={(event, newValue) => { console.log(newValue); }} defaultValue={2} /> <Typography component="legend">Read only</Typography> <Rating name="read-only" value={value} readOnly /> <Typography component="legend">Disabled</Typography> <Rating name="disabled" value={value} disabled /> <Typography component="legend">No rating given</Typography> <Rating name="no-value" value={null} /> </Box> ); }