Skip to content

Skeleton

Skeleton

A decorative loading placeholder. Each Skeleton is aria-hidden (a consumer aria-hidden overrides it); wrap the placeholders of a loading region in SkeletonGroup (Skeleton.Group), which marks it busy, gives it a visually hidden "Loading" label and sets the size, shape, animation and appearance of the placeholders inside it.

- size is a preset in pixels (Fluent's sizes, 8 to 128): the height of a rounded line, the width and height of a circular or square box. A placeholder with no height is 16px tall.
- animation="wave" sweeps a highlight across it instead of pulsing; both stop for reduced motion. appearance="translucent" lets what is behind it show.
- In forced-colors mode the placeholders are painted GrayText. In React Server Components use the flat export SkeletonGroup instead of Skeleton.Group.

Examples

Rectangle

export const Rectangle: Story = {
  args: {
    width: 200,
    height: 120,
  },
};

Circle

export const Circle: Story = {
  args: {
    shape: 'circular',
    width: 48,
    height: 48,
  },
};

Square

export const Square: Story = {
  args: {
    shape: 'square',
    width: 64,
    height: 64,
  },
};

Sizes

export const Sizes: Story = {
  render: (args) => (
    <div className="flex flex-col gap-3">
      <Skeleton width={200} height={12} {...args} />
      <Skeleton width={160} height={12} {...args} />
      <Skeleton width={180} height={12} {...args} />
      <Skeleton width={300} height={80} {...args} />
      <div className="flex gap-2">
        <Skeleton shape="circular" width={32} height={32} />
        <Skeleton shape="circular" width={48} height={48} />
        <Skeleton shape="circular" width={64} height={64} />
      </div>
    </div>
  ),
};

Group

Loading profile
export const Group: Story = {
  render: (args) => (
    <Skeleton.Group label="Loading profile" className="flex items-center gap-3">
      <Skeleton shape="circular" width={40} height={40} />
      <div className="flex flex-col gap-2">
        <Skeleton width={160} height={12} {...args} />
        <Skeleton width={120} height={12} {...args} />
      </div>
    </Skeleton.Group>
  ),
};

Size Presets

export const SizePresets: Story = {
  render: ({ size: _size, ...args }) => (
    <div className="flex flex-col gap-3">
      {([8, 12, 16, 20, 24, 32, 40] as const).map((size) => (
        <Skeleton key={size} {...args} size={size} width={size * 8} />
      ))}
      <div className="flex items-end gap-2">
        {([16, 24, 32, 48, 64] as const).map((size) => (
          <Skeleton key={size} {...args} shape="circular" size={size} />
        ))}
      </div>
    </div>
  ),
};

Wave

export const Wave: Story = {
  args: { animation: 'wave' },
  render: ({ animation, ...args }) => (
    <div className="flex w-72 flex-col gap-3">
      <Skeleton {...args} animation={animation} width="100%" height={16} />
      <Skeleton {...args} animation={animation} width="70%" height={16} />
      <Skeleton {...args} animation={animation} width="100%" height={80} />
    </div>
  ),
};

Translucent

export const Translucent: Story = {
  render: ({ appearance: _appearance, ...args }) => (
    <div className="flex w-72 flex-col gap-3 rounded bg-wave-inverted p-4">
      <Skeleton {...args} appearance="translucent" width="100%" />
      <Skeleton {...args} appearance="translucent" width="60%" />
    </div>
  ),
};

Group Defaults

Loading people
export const GroupDefaults: Story = {
  render: () => (
    <Skeleton.Group
      label="Loading people"
      animation="wave"
      size={32}
      className="flex flex-col gap-3"
    >
      {[0, 1, 2].map((row) => (
        <div key={row} className="flex items-center gap-3">
          <Skeleton shape="circular" />
          <Skeleton width={160 - row * 20} />
          <Skeleton shape="square" size={16} />
        </div>
      ))}
    </Skeleton.Group>
  ),
};

Props

NameTypeRequiredDefaultDescription
widthstring | numberNo

Width of the skeleton placeholder.

heightstring | numberNo

Height of the skeleton placeholder.

size8 | 12 | 16 | 20 | 24 | 28 | 32 | 36 | 40 | 48 | 56 | 64 | 72 | 96 | 120 | 128Nothe group's size, else 16 when it has no `height`

Preset size in pixels, as Fluent's SkeletonItem: the height of a rounded placeholder (its width fills the line), the width and height of a circular or square one. A width or height of yours sets that dimension instead. Without a size, a surrounding Skeleton.Group gives one; without that, a placeholder that has no height is 16px tall (a circular or square one with neither dimension is 16px square), where 0.x drew none. The root carries data-size while a size is set.

shape'circular' | 'square' | 'rounded'No'rounded', or the group's shape

Geometry of the placeholder: rounded (4px radius), circular (avatars) or square. Without one, a surrounding Skeleton.Group gives it. Fluent's shape (rectangle, circle, square).

animation'pulse' | 'wave'No'pulse', or the group's animation

pulse fades the placeholder in and out; wave sweeps a highlight across it (Fluent's default animation, wave; WaveUI keeps pulse). Both stop for reduced motion. Without one, a surrounding Skeleton.Group gives it.

appearance'opaque' | 'translucent'No'opaque', or the group's appearance

opaque fills with the skeleton color; translucent fills with the page color at 60% so an image or a colored surface shows through. Without one, a surrounding Skeleton.Group gives it.

refReact.Ref<HTMLDivElement>No

Any other prop is passed to the element it renders (HTMLDivElement).

Parts

  • Skeleton.Group

Stable class names

PartClass
rootwave-skeleton