Phi
Skeleton Line
@dicehub/phiv1.0.0-beta.1

Skeleton Line

A skeleton loading placeholder for text content.

<script setup>
import { SkeletonLine } from "@dicehub/phi/components/skeleton-line";
</script>

<template>
  <div class="skeleton-line-stack">
    <SkeletonLine />
    <SkeletonLine />
    <SkeletonLine />
  </div>
</template>

Installation

Barrel

import { SkeletonLine } from "@dicehub/phi";

Granular

import { SkeletonLine } from "@dicehub/phi/components/skeleton-line";

Examples

Custom Widths

Control the randomized width range for more natural-looking skeletons.

<script setup>
import { SkeletonLine } from "@dicehub/phi/components/skeleton-line";
</script>

<template>
  <div class="skeleton-line-stack">
    <SkeletonLine :min-width="80" :max-width="100" />
    <SkeletonLine :min-width="60" :max-width="80" />
    <SkeletonLine :min-width="40" :max-width="60" />
  </div>
</template>

Custom Height

Override the default height using CSS classes via className. The default height is 0.5rem.

<script setup>
import { SkeletonLine } from "@dicehub/phi/components/skeleton-line";
</script>

<template>
  <div class="skeleton-line-stack">
    <SkeletonLine class-name="h-2" />
    <SkeletonLine class-name="h-4" />
    <SkeletonLine class-name="h-6" />
    <SkeletonLine class-name="h-8" />
  </div>
</template>

Block Height

Use blockHeight to set the height of a container that vertically centers the skeleton line. Numbers are treated as px; strings are passed through as CSS values.

<script setup>
import { SkeletonLine } from "@dicehub/phi/components/skeleton-line";
</script>

<template>
  <div class="skeleton-line-stack skeleton-line-block-demo">
    <div class="skeleton-line-block-demo__row">
      <span>32px</span>
      <SkeletonLine :block-height="32" />
    </div>
    <div class="skeleton-line-block-demo__row">
      <span>48px</span>
      <SkeletonLine :block-height="48" />
    </div>
    <div class="skeleton-line-block-demo__row">
      <span>64px</span>
      <SkeletonLine :block-height="64" />
    </div>
  </div>
</template>

Card Loading State

Use skeleton lines to create loading states for cards and content areas.

<script setup>
import { SkeletonLine } from "@dicehub/phi/components/skeleton-line";
</script>

<template>
  <div class="skeleton-card">
    <div class="skeleton-card__title">
      <SkeletonLine :min-width="40" :max-width="60" />
    </div>
    <div class="skeleton-line-stack skeleton-line-stack--compact">
      <SkeletonLine />
      <SkeletonLine />
      <SkeletonLine :min-width="50" :max-width="70" />
    </div>
  </div>
</template>

API Reference

PropTypeDefaultDescription
minWidthnumber30Minimum randomized line width as a percentage.
maxWidthnumber100Maximum randomized line width as a percentage.
minDurationnumber1.3Minimum shimmer animation duration in seconds.
maxDurationnumber1.7Maximum shimmer animation duration in seconds.
minDelaynumber0Minimum shimmer animation delay in seconds.
maxDelaynumber0.5Maximum shimmer animation delay in seconds.
blockHeightstring | number-Optional block height that vertically centers the line.
classNamestring-Additional CSS classes applied to the skeleton line.