Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import Skeleton from '@mui/material/Skeleton';
import Stack from '@mui/material/Stack';
import Typography from '@mui/material/Typography';

const variants = ['h1', 'h3', 'body1', 'caption'];

export default function SkeletonTextWithCustomRadius() {
return (
<Stack spacing={1}>
{variants.map((variant) => (
<Typography component="div" key={variant} variant={variant}>
<Skeleton variant="text" sx={{ borderRadius: 1 }} />
</Typography>
))}
</Stack>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import Skeleton from '@mui/material/Skeleton';
import Stack from '@mui/material/Stack';
import Typography, { TypographyProps } from '@mui/material/Typography';

const variants = [
'h1',
'h3',
'body1',
'caption',
] as readonly TypographyProps['variant'][];

export default function SkeletonTextWithCustomRadius() {
return (
<Stack spacing={1}>
{variants.map((variant) => (
<Typography component="div" key={variant} variant={variant}>
<Skeleton variant="text" sx={{ borderRadius: 1 }} />
</Typography>
))}
</Stack>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{variants.map((variant) => (
<Typography component="div" key={variant} variant={variant}>
<Skeleton variant="text" sx={{ borderRadius: 1 }} />
</Typography>
))}
6 changes: 6 additions & 0 deletions docs/data/material/components/skeleton/skeleton.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ It works well when it comes to typography as its height is set using `em` units.

{{"demo": "SkeletonTypography.js", "defaultCodeOpen": false}}

To keep that typography sizing behavior while changing the shape, keep
`variant="text"` and customize the border radius with the `sx` prop instead of
switching to `rectangular` or `rounded`.

{{"demo": "SkeletonTextWithCustomRadius.js", "defaultCodeOpen": false}}

But when it comes to other components, you may not want to repeat the width and
height. In these instances, you can pass `children` and it will
infer its width and height from them.
Expand Down
Loading