Files
react-test/docs/data/material/components/grid-legacy/AutoGridNoWrap.tsx

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

58 lines
1.7 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 Paper from '@mui/material/Paper';
import Grid from '@mui/material/GridLegacy';
import Avatar from '@mui/material/Avatar';
import Typography from '@mui/material/Typography';
const StyledPaper = styled(Paper)(({ theme }) => ({
backgroundColor: '#fff',
...theme.typography.body2,
padding: theme.spacing(2),
maxWidth: 400,
color: (theme.vars ?? theme).palette.text.primary,
...theme.applyStyles('dark', {
backgroundColor: '#1A2027',
}),
}));
const message = `Truncation should be conditionally applicable on this long line of text
as this is a much longer line than what the container can support. `;
export default function AutoGridNoWrap() {
return (
<Box sx={{ flexGrow: 1, overflow: 'hidden', px: 3 }}>
<StyledPaper sx={{ my: 1, mx: 'auto', p: 2 }}>
<Grid container spacing={2} wrap="nowrap">
<Grid item>
<Avatar>W</Avatar>
</Grid>
<Grid item xs zeroMinWidth>
<Typography noWrap>{message}</Typography>
</Grid>
</Grid>
</StyledPaper>
<StyledPaper sx={{ my: 1, mx: 'auto', p: 2 }}>
<Grid container spacing={2} wrap="nowrap">
<Grid item>
<Avatar>W</Avatar>
</Grid>
<Grid item xs>
<Typography noWrap>{message}</Typography>
</Grid>
</Grid>
</StyledPaper>
<StyledPaper sx={{ my: 1, mx: 'auto', p: 2 }}>
<Grid container spacing={2} wrap="nowrap">
<Grid item>
<Avatar>W</Avatar>
</Grid>
<Grid item xs>
<Typography>{message}</Typography>
</Grid>
</Grid>
</StyledPaper>
</Box>
);
}