/
githubmirror
/
material-ui
Обзор
Документация
Войти
/
githubmirror
/
material-ui
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
docs/data/material/components/cards/SelectActionCard.tsx
67 строк
2 KB
Siriwat K
[material-ui][system] Remove deprecated system props from Box, Stack, Typography (#48072)
25 мар 2026, 05:44
Не верифицирован
25 мар 2026, 05:44
8663368
Код
Авторство
О чём код?
import * as React from 'react'; import Box from '@mui/material/Box'; import Card from '@mui/material/Card'; import CardContent from '@mui/material/CardContent'; import Typography from '@mui/material/Typography'; import CardActionArea from '@mui/material/CardActionArea'; const cards = [ { id: 1, title: 'Plants', description: 'Plants are essential for all life.', }, { id: 2, title: 'Animals', description: 'Animals are a part of nature.', }, { id: 3, title: 'Humans', description: 'Humans depend on plants and animals for survival.', }, ]; function SelectActionCard() { const [selectedCard, setSelectedCard] = React.useState(0); return ( <Box sx={{ width: '100%', display: 'grid', gridTemplateColumns: 'repeat(auto-fill, minmax(min(200px, 100%), 1fr))', gap: 2, }} > {cards.map((card, index) => ( <Card key={card.id}> <CardActionArea onClick={() => setSelectedCard(index)} data-active={selectedCard === index ? '' : undefined} sx={{ height: '100%', '&[data-active]': { backgroundColor: 'action.selected', '&:hover': { backgroundColor: 'action.selectedHover', }, }, }} > <CardContent sx={{ height: '100%' }}> <Typography variant="h5" component="div"> {card.title} </Typography> <Typography variant="body2" sx={{ color: 'text.secondary' }}> {card.description} </Typography> </CardContent> </CardActionArea> </Card> ))} </Box> ); } export default SelectActionCard;