Files
react-test/docs/data/joy/components/badge/NumberBadge.tsx
how2ice 005cf56baf
Some checks failed
No response / noResponse (push) Has been cancelled
CI / Continuous releases (push) Has been cancelled
CI / test-dev (macos-latest) (push) Has been cancelled
CI / test-dev (ubuntu-latest) (push) Has been cancelled
CI / test-dev (windows-latest) (push) Has been cancelled
Maintenance / main (push) Has been cancelled
Scorecards supply-chain security / Scorecards analysis (push) Has been cancelled
CodeQL / Analyze (push) Has been cancelled
init project
2025-12-12 14:26:25 +09:00

65 lines
1.6 KiB
TypeScript

import * as React from 'react';
import Badge from '@mui/joy/Badge';
import Box from '@mui/joy/Box';
import IconButton from '@mui/joy/IconButton';
import Typography from '@mui/joy/Typography';
import Checkbox from '@mui/joy/Checkbox';
import Add from '@mui/icons-material/Add';
import Remove from '@mui/icons-material/Remove';
export default function NumberBadge() {
const [count, setCount] = React.useState(0);
const [showZero, setShowZero] = React.useState(false);
return (
<Box
sx={{
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
gap: 2,
mt: 4,
}}
>
<Badge badgeContent={count} showZero={showZero}>
<Typography level="h1" component="h2">
🛍
</Typography>
</Badge>
<Box
sx={{
display: 'flex',
alignItems: 'center',
gap: 2,
pt: 4,
mb: 2,
borderTop: '1px solid',
borderColor: 'background.level1',
}}
>
<IconButton
size="sm"
variant="outlined"
onClick={() => setCount((c) => c - 1)}
>
<Remove />
</IconButton>
<Typography textColor="text.secondary" sx={{ fontWeight: 'md' }}>
{count}
</Typography>
<IconButton
size="sm"
variant="outlined"
onClick={() => setCount((c) => c + 1)}
>
<Add />
</IconButton>
</Box>
<Checkbox
onChange={(event) => setShowZero(event.target.checked)}
checked={showZero}
label="show zero"
/>
</Box>
);
}