If you answer yes, we store and analyse information that helps us improve the website. You can change your choice at any time at the bottom of the page. More about what we store and why.

We also store necessary information that cannot be opted out of. This makes the website work and keeps it secure.

Skip to main content

What are you looking for?

Try searching for…

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.

Press Enter to start editing
<span
  aria-hidden="true"
  class="ds-skeleton"
  style="width:200px;height:100px"
></span>
const Preview = () => {
  return <Skeleton width={200} height={100} />;
};

render(<Preview />)

Usage

Add the class name ds-skeleton to a <span> with aria-hidden="true". Change the variant with data-variant, and use data-text for the text variant. You can set the size with the style attribute or CSS.

CSS variables and data attributes

Sizes are controlled with data-size and colors with data-color. The component will inherit from the closest parent where these are set.

CSS Variables
NameValue
--dsc-skeleton-animationds-skeleton-opacity-fade var(--dsc-skeleton-animation-duration) linear infinite alternate
--dsc-skeleton-animation-duration0.8s
--dsc-skeleton-backgroundvar(--ds-color-neutral-surface-tinted)
Data Attributes
NameValue
data-variantcircle, text

React

Skeleton

width
Description

The width of the component

Type
string | number
height
Description

The height of the component

Type
string | number
variant
Description

The shape variant

Type
"rectangle" | "circle" | "text"
Default
'rectangle'
asChild
Description

Change the default rendered element for the one passed as a child, merging their props and behavior.

Type
boolean
Default
false
characters
Description

@deprecated This prop has no effect. Use `width` or supply text as children instead

Type
number
NameTypeDefaultDescription
widthstring | number-

The width of the component

heightstring | number-

The height of the component

variant"rectangle" | "circle" | "text"'rectangle'

The shape variant

asChildbooleanfalse

Change the default rendered element for the one passed as a child, merging their props and behavior.

charactersnumber-

@deprecated This prop has no effect. Use `width` or supply text as children instead

Edit this page on github.com (opens in a new tab)