/
githubmirror
/
material-ui
Обзор
Документация
Войти
/
githubmirror
/
material-ui
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
docs/data/material/components/lists/SwitchListSecondary.js
62 строки
2 KB
Siriwat K
[Checkbox][Radio][Switch] Remove deprecated inputProps and inputRef (#48059)
23 мар 2026, 09:29
Не верифицирован
23 мар 2026, 09:29
58cf9c2
Код
Авторство
О чём код?
import * as React from 'react'; import List from '@mui/material/List'; import ListItem from '@mui/material/ListItem'; import ListItemIcon from '@mui/material/ListItemIcon'; import ListItemText from '@mui/material/ListItemText'; import ListSubheader from '@mui/material/ListSubheader'; import Switch from '@mui/material/Switch'; import WifiIcon from '@mui/icons-material/Wifi'; import BluetoothIcon from '@mui/icons-material/Bluetooth'; export default function SwitchListSecondary() { const [checked, setChecked] = React.useState(['wifi']); const handleToggle = (value) => () => { const currentIndex = checked.indexOf(value); const newChecked = [...checked]; if (currentIndex === -1) { newChecked.push(value); } else { newChecked.splice(currentIndex, 1); } setChecked(newChecked); }; return ( <List sx={{ width: '100%', maxWidth: 360, bgcolor: 'background.paper' }} subheader={<ListSubheader>Settings</ListSubheader>} > <ListItem> <ListItemIcon> <WifiIcon /> </ListItemIcon> <ListItemText id="switch-list-label-wifi" primary="Wi-Fi" /> <Switch edge="end" onChange={handleToggle('wifi')} checked={checked.includes('wifi')} slotProps={{ input: { 'aria-labelledby': 'switch-list-label-wifi' }, }} /> </ListItem> <ListItem> <ListItemIcon> <BluetoothIcon /> </ListItemIcon> <ListItemText id="switch-list-label-bluetooth" primary="Bluetooth" /> <Switch edge="end" onChange={handleToggle('bluetooth')} checked={checked.includes('bluetooth')} slotProps={{ input: { 'aria-labelledby': 'switch-list-label-bluetooth' }, }} /> </ListItem> </List> ); }