Skip to content
API 风格:

Skeleton ​

Placeholder preview before content loads. Placeholder blocks are aria-hidden from screen readers; the container signals state via aria-busy and aria-live. The pulse animation respects prefers-reduced-motion.

Basic Usage ​

Basic Usage
vue
<script setup lang="ts">
import { ref } from 'vue'

const skeletonLoading = ref(true)
</script>

<template>
  <!-- Basic Usage -->
  <LhSkeleton :rows="3" :loading="skeletonLoading">
    <p>Content loaded.</p>
  </LhSkeleton>
  <!-- Toggle loading -->
  <LhButton size="small" @click="skeletonLoading = !skeletonLoading">
    {{ skeletonLoading ? 'Show content' : 'Show skeleton' }}
  </LhButton>
</template>
vue
<script>
export default {
  data() {
    return { skeletonLoading: true }
  },
}
</script>

<template>
  <!-- Basic Usage -->
  <LhSkeleton :rows="3" :loading="skeletonLoading">
    <p>Content loaded.</p>
  </LhSkeleton>
  <!-- Toggle loading -->
  <LhButton size="small" @click="skeletonLoading = !skeletonLoading">
    {{ skeletonLoading ? 'Show content' : 'Show skeleton' }}
  </LhButton>
</template>

With Avatar ​

With Avatar
vue
<script setup lang="ts">
</script>

<template>
  <LhSkeleton avatar :rows="2" />
</template>
vue
<script>
export default {}
</script>

<template>
  <LhSkeleton avatar :rows="2" />
</template>

Without Animation ​

Static
vue
<script setup lang="ts">
</script>

<template>
  <LhSkeleton :rows="3" :animated="false" />
</template>
vue
<script>
export default {}
</script>

<template>
  <LhSkeleton :rows="3" :animated="false" />
</template>

SkeletonItem ​

SkeletonItem
vue
<script setup lang="ts">
</script>

<template>
  <LhSkeletonItem variant="circle" />
  <LhSkeletonItem variant="rect" style="width: 120px; height: 60px" />
</template>
vue
<script>
export default {}
</script>

<template>
  <LhSkeletonItem variant="circle" />
  <LhSkeletonItem variant="rect" style="width: 120px; height: 60px" />
</template>

Skeleton API ​

Props ​

PropDescriptionTypeDefault
loadingLoading state (false renders the default slot)booleantrue
rowsNumber of text rowsnumber3
avatarInclude a circle avatar placeholderbooleanfalse
animatedEnable the pulse animationbooleantrue
sxsx quick-layout propertiesLhSxProps—

Slots ​

SlotDescription
defaultReal content rendered when loading is false

SkeletonItem API ​

Props ​

PropDescriptionTypeDefault
variantPlaceholder shape'text' | 'rect' | 'circle''text'
animatedEnable the pulse animationbooleantrue
sxsx quick-layout propertiesLhSxProps—

Theme Variables ​

VariableDescriptionDefault
--lh-skeleton-bgPlaceholder base colorInk tone (text-regular) at 10% opacity
--lh-skeleton-highlightShimmer highlight colorBase color lightened 45% toward white
--lh-skeleton-radiusBase radius--lh-border-radius-small

Accessibility ​

  • Placeholders are aria-hidden="true" and skipped by screen readers
  • Container has aria-busy="true" + aria-live="polite" — the content swap is announced
  • The pulse animation is disabled under prefers-reduced-motion: reduce

Type Definitions ​

The TypeScript type structures exported by this component (auto-extracted from packages/components/skeleton/src/types.ts and @lh-ui/share/core/* sources; click each entry to expand; see the Props table above for attribute descriptions):

LhSkeletonProps
ts
export interface LhSkeletonProps {
  loading?: boolean
  rows?: number
  avatar?: boolean
  animated?: boolean
  sx?: LhSxProps
}
LhSkeletonItemProps
ts
export interface LhSkeletonItemProps {
  variant?: LhSkeletonVariant
  animated?: boolean
  sx?: LhSxProps
}
LhSkeletonVariant (from @lh-ui/share/core/skeleton)
ts
export type LhSkeletonVariant = 'text' | 'rect' | 'circle'

Beauty of tradition, foundation of code