Components
Skeleton
Skeleton is used to indicate that content on a page is loading. It provides the user with a visual hint of what the content will eventually look like.
HTML
Press Enter to start editing
Unable to parse html
const Preview = () => { return <Skeleton width={200} height={100} />; }; render(<Preview />)
Use skeleton when
- you need to indicate that content on a page is in the process of loading
- you want to show users what the layout of the content will look like once it has loaded
- the content is expected to take more than one second to load
Avoid skeleton when
- you need to indicate that the system is working on a task the user must wait for, use a spinner instead
Example
Variants
Skeleton comes in three variants: rectangle, circle, and text.
HTML
Press Enter to start editing
Unable to parse html
const Components = () => { return ( <> <Skeleton variant='circle' width='50px' height='50px' /> <Skeleton variant='rectangle' width='100px' height='50px' /> <Paragraph> <Skeleton variant='text' width='10' /> </Paragraph> </> ); }; render(<Components />)
Usage example
HTML
Press Enter to start editing
Unable to parse html
const UsageExample = () => { return ( <> <Skeleton height='150px' /> <div style={{ display: 'flex', gap: '10px', alignItems: 'center', padding: '5px 0 5px 0', }} > <Skeleton variant='circle' width='30px' height='30px' /> <Heading> <Skeleton variant='text'>En medium tittel</Skeleton> </Heading> </div> <Skeleton variant='text' width='140' /> </> ); }; render(<UsageExample />)
Text variant
HTML
Press Enter to start editing
Unable to parse html
const Text = () => { return ( <> <div style={{ flex: '1 1 200px' }}> <Heading>En tittel</Heading> <Paragraph data-size='sm'> Her er en paragraf som går over flere linjer </Paragraph> </div> <div style={{ flex: '1 1 200px' }}> <Heading> <Skeleton variant='text'>En tittel</Skeleton> </Heading> <Paragraph data-size='sm'> <Skeleton variant='text' width={40} /> </Paragraph> </div> </> ); }; render(<Text />)
Guidelines
Skeleton is an alternative to spinner when you want to indicate that content is loading. It helps users understand what is coming and can make the waiting time feel shorter.
Choose the skeleton variant based on the type of content being loaded, such as headings, text blocks or images. Try to mimic the structure of the actual content to make the transition to the fully loaded content feel smooth.
Edit this page on github.com (opens in a new tab)