---
title: "Skeleton · UI SDK — StyleX Blocks"
description: "Loading placeholders with pulse and shine animations that respect reduced motion."
url: "https://stylexblocks.com/components/ui-sdk/skeleton/"
agent:
  instructions: "Use this search API to find relevant components and blocks across this site with keywords or natural-language queries, instead of crawling individual pages. Results are returned in Markdown."
  endpoint: "https://stylexblocks.com/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://developers.cloudflare.com/ai-search/how-to/search-for-agents/"
---

# Skeleton

Loading placeholders with pulse and shine animations that respect reduced motion.

- Behavior engine: UI SDK
- Also available for: [Ark UI](https://stylexblocks.com/components/ark-ui/skeleton.md), [Base UI](https://stylexblocks.com/components/base-ui/skeleton.md)
- Category: Feedback
- Variants: pulse, shine, none
- HTML page: https://stylexblocks.com/components/ui-sdk/skeleton/

## Install

Configure the project once (sets the behavior engine and import aliases):

```sh
npx stylexblocks init --style ui-sdk
```

Then add the item as source you own:

```sh
npx stylexblocks add skeleton
```

Equivalent: `npx shadcn add @stylexblocks/skeleton`. Registry item JSON: https://stylexblocks.com/r/ui-sdk/skeleton.json

## Usage

```tsx
import { Skeleton } from "#components/ui/ui-sdk/skeleton.tsx";

export function Example({ loaded }: { loaded: boolean }) {
  return (
    <>
      {/* variant + loading props resolve through the StyleX recipe and are
          exposed as data-variant / data-loading attributes */}
      <Skeleton variant="pulse" />

      {/* flip loading off to fade the loaded content back in; the render
          prop wraps your real element */}
      <Skeleton
        variant="shine"
        loading={loaded ? "false" : "true"}
        render={<p>Ready when you are.</p>}
      />
    </>
  );
}
```

## Source

`components/ui/ui-sdk/skeleton.tsx`

```tsx
import * as stylex from "@stylexjs/stylex";
import { createComponent } from "#lib/ui-sdk/create-component.tsx";
import { defineRecipe } from "#lib/recipe-props.ts";
import { semanticColors } from '@stylexblocks/ui/semantic-tokens/colors.stylex.ts'
import { semanticRadii } from '@stylexblocks/ui/semantic-tokens/radii.stylex.ts'

const skeletonStyles = stylex.create({
  base: {},
})

const skeletonLoadings = stylex.create({
  true: {
    borderRadius: semanticRadii.panel,
    boxShadow: 'none',
    backgroundClip: 'padding-box',
    cursor: 'default',
    color: 'transparent',
    pointerEvents: 'none',
    userSelect: 'none',
    flexShrink: 0,
  },
  false: {
    backgroundColor: 'unset',
    animationName: 'fade-in',
    animationDuration: 'var(--fade-duration, 0.1s)',
    animationTimingFunction: 'ease-out',
  },
})

const skeletonVariants = stylex.create({
  pulse: {
    backgroundColor: semanticColors.bgEmphasized,
    animationName: 'pulse',
    animationTimingFunction: 'cubic-bezier(0.4, 0, 0.6, 1)',
    animationIterationCount: 'infinite',
    animationDuration: 'var(--duration, 1.2s)',
  },
  shine: {
    '--animate-from': '200%',
    '--animate-to': '-200%',
    '--start-color': semanticColors.bgMuted,
    '--end-color': semanticColors.bgEmphasized,
    backgroundImage:
      'linear-gradient(270deg,var(--start-color),var(--end-color),var(--end-color),var(--start-color))',
    backgroundSize: '400% 100%',
    animationName: 'bg-position',
    animationDuration: 'var(--duration, 5s)',
    animationTimingFunction: 'ease-in-out',
    animationIterationCount: 'infinite',
  },
  none: {
    animationName: 'none',
    backgroundColor: semanticColors.bgMuted,
  },
})

export type SkeletonLoading = keyof typeof skeletonLoadings

export type SkeletonVariant = keyof typeof skeletonVariants

/**
 * Skeleton — recipe and component colocated in one file. Variant and
 * loading props resolve mechanically from the axis maps (`loading="false"`
 * fades the loaded content back in). Composition via `render`.
 */
const skeletonRecipe = defineRecipe({
  styles: skeletonStyles,
  axes: { variant: skeletonVariants, loading: skeletonLoadings },
  defaultVariants: { variant: "pulse", loading: "true" },
});

export const Skeleton = createComponent("div", skeletonRecipe, "Skeleton");

export type SkeletonProps = React.ComponentProps<typeof Skeleton>;
```
