Skip to content

Skeleton ​

Skeleton is a placeholder block shown while content loads. It renders an empty, pulsing <div> using the surface-muted token, sized with width/height and shaped with rounded, so layouts can reserve space and avoid content jumps.

vue
<script setup lang="ts">
import { Skeleton } from '@myghf/ui'
</script>

<template>
  <Skeleton width="12rem" height="1rem" />
  <Skeleton width="2.5rem" height="2.5rem" rounded="full" />
</template>

Examples ​

Shapes, corners, and sizes ​

Compose several skeletons to mirror the layout they stand in for — circles for avatars, short bars for text lines, and a larger block with rounded="lg" for a card. A skeleton is decorative by default; give it a default slot when you need content inside the placeholder (for example a centred label).

Slot content replaces the empty block

vue
<script setup lang="ts">
import { Skeleton } from '@myghf/ui'
</script>

<template>
  <div class="flex flex-col gap-6">
    <div class="flex items-center gap-4">
      <Skeleton width="3rem" height="3rem" rounded="full" />
      <Skeleton width="3rem" height="3rem" rounded="lg" />
      <Skeleton width="3rem" height="3rem" rounded="none" />
    </div>

    <div class="flex max-w-sm flex-col gap-2">
      <Skeleton width="40%" height="0.75rem" />
      <Skeleton width="100%" height="0.75rem" />
      <Skeleton width="80%" height="0.75rem" />
    </div>

    <div class="flex max-w-sm items-center gap-3">
      <Skeleton width="2.5rem" height="2.5rem" rounded="full" />
      <div class="flex flex-1 flex-col gap-2">
        <Skeleton width="60%" height="0.75rem" />
        <Skeleton width="90%" height="0.75rem" />
      </div>
    </div>

    <Skeleton width="12rem" height="5rem" rounded="lg">
      <p class="flex h-full items-center justify-center text-sm text-muted">
        Slot content replaces the empty block
      </p>
    </Skeleton>
  </div>
</template>

Props ​

PropTypeDefaultDescription
rounded'none' | 'sm' | 'md' | 'lg' | 'full''md'Corner radius: rounded-sm, rounded-md, rounded-lg, or rounded-full. none leaves the corners square.
widthstringundefinedAny CSS length, applied as an inline width (for example '12rem' or '40%').
heightstringundefinedAny CSS length, applied as an inline height (for example '1rem' or '2.5rem').

Events ​

Skeleton declares no custom events. Because it has a single root element, native listeners and attributes such as @click and class fall through to the root <div>.

Slots ​

SlotDescription
defaultOptional content rendered inside the placeholder. When omitted, the block stays empty and shows only the pulsing background.

Exposed methods ​

None. Skeleton does not call defineExpose.

Accessibility ​

  • A skeleton is purely decorative, so it deliberately carries no role and makes no announcement. Screen readers skip an empty <div>, which is the desired behaviour.
  • Pass aria-hidden="true" when the skeleton sits next to real content and you want to guarantee it is ignored. Attributes fall through to the root element.
  • Mark the region that is loading with aria-busy="true" on its container, and remove the skeletons once the content arrives, so assistive technology is told when the load has finished.
  • Do not rely on the animation alone to convey status; pair skeletons with text or a live region when the wait could be long.

Dark mode & RTL ​

  • The fill comes from the bg-surface-muted token, which is defined for both the light and dark themes, so no extra dark-mode classes are needed.
  • The component uses no directional utilities (no margins, padding, or transforms), so it renders identically in LTR and RTL.

Released under the MIT License.