Skip to content

The open alternative to Salesforce, designed for AI.

3.2 KB
Raw Blame
---
title: Skeleton
description: Show themed placeholder shapes while content loads.
---

import { PageBanner } from "/snippets/page-banner.mdx"

import { StoryEmbed } from '/snippets/ui/StoryEmbed.mdx';

import SkeletonReference from '/snippets/ui/generated/feedback/skeleton.mdx';

## Overview

`Skeleton` provides a placeholder shape with theme colors and a moving highlight. Compose shapes in the layout of the content being loaded. The application owns loading state and feature-specific layouts.

<StoryEmbed
  storyId="ui-feedback-skeleton--display"
  title="Skeleton shapes"
  height={110}
/>

## Usage

```tsx
import { Skeleton, SKELETON_HEIGHT_SIZES } from 'twenty-ui/primitives/feedback';
import { Text } from 'twenty-ui/primitives/typography';

export const LoadingProfile = () => (
  <Text render={<div />} style={{ display: 'flex', gap: 16 }}>
    <Skeleton width={40} height={40} borderRadius="50%" />
    <Text
      render={<div />}
      style={{ display: 'flex', flexDirection: 'column', gap: 8 }}
    >
      <Skeleton width={180} height={SKELETON_HEIGHT_SIZES.s} />
      <Skeleton width={120} height={SKELETON_HEIGHT_SIZES.xs} />
    </Text>
  </Text>
);
```

Skeleton renders as a block and never grows wider than its container. Use `layout="inline"` to place a placeholder inside a line of text.

Numeric dimensions use pixels. CSS lengths such as percentages and `em` are also supported. Without dimensions, the placeholder fills the available width and uses the inherited font height. Use equal dimensions and `borderRadius="50%"` for a circle.

`SKELETON_HEIGHT_SIZES` provides shared heights for `xs` (13px), `s` (16px), `m` (24px), `l` (32px) and `xl` (40px). Keep layout-specific dimensions in the application.

Each `Skeleton` renders one placeholder. Keep repeated lines, text-line spacing and loading regions in application components that wrap the primitive.

## Motion and accessibility

Skeletons are decorative and have `aria-hidden="true"` by default. Keep loading announcements in a host-owned status region instead of announcing each shape. Skeleton does not accept children.

The highlight moves from left to right on a 1.5-second ease-in-out loop and is hidden when the user prefers reduced motion. Pass `animated={false}` for a static placeholder.

<StoryEmbed
  storyId="ui-feedback-skeleton--static"
  title="Static skeleton"
  height={90}
/>

## Composition and theme

Native props, `className`, `style` and `ref` target the placeholder span. Use `render` to compose another element. Explicit native styles override dimension and color props.

The base and highlight colors default to the theme tertiary background and lighter transparent background. Use `baseColor`, `highlightColor` and `borderRadius` to override them. Corners stay round, including when the theme uses squircles. The default radius uses the `smRound` theme token (4px). Pass `themeCssVariables.border.radius.mdRound` from `twenty-ui/theme` for 8px corners. Custom pixel and CSS radii remain supported, including `borderRadius={80}` for a narrow capsule and `borderRadius="50%"` for a circle. No skeleton-specific provider or stylesheet import is needed after loading `twenty-ui/style.css` and the UI theme.

## Props

<SkeletonReference />

<PageBanner illustration="section-ui-primitives" />