Skip to main content

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.

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

Usage

Examples

Variants

Usage Example

Text Variant

HTML

Put the class name ds-skeleton on a <span> with aria-hidden="true".

You change the variant with data-variant.

If you have the text variant, set data-text with as much text as you want it to imitate. In react we use a hyphen ("-") in data-text. The text variant should be in a <p> or heading element to get the correct font size.

If you want to set the size you can do this with the style attribute, or with CSS.

CSS variables and data attributes

CSS Variables
NameValue
--dsc-skeleton-animation-duration0.8s
--dsc-skeleton-animationds-skeleton-opacity-fade var(--dsc-skeleton-animation-duration) linear infinite alternate
--dsc-skeleton-backgroundvar(--ds-color-neutral-surface-tinted)
Data Attributes
NameValue
data-variantcircle, text
Edit this page on github.com (opens in a new tab)