Components/Skeleton

Skeleton

Loading placeholders and structure hints

VerifiedSince 0.3.4

Usage

Skeleton

Text and avatar placeholders

Loading demo...

Card Placeholder

Skeletons inside cards for feeds.

Loading demo...

Best Practices

  • Match skeleton width, height, line count, and radius to the final content so loading does not create a second layout.
  • Use TxSkeleton for configurable text, rectangle, and avatar placeholders; use TxCardSkeleton or TxListItemSkeleton when their fixed structure matches the final surface.
  • Keep loading=false as the handoff point to real content instead of rendering skeleton and content in separate branches.
  • Do not use skeletons as decorative gray chrome. If the final content is unknown, prefer a neutral empty or loading state with copy.
  • For a table, use TxDataTable with loadingVariant="skeleton": it draws placeholder rows shaped like its columns on the first load and keeps the rows during a refresh. Its default loading overlay suits a short local wait.

API Reference

Props

PropertyTypeDefaultDescription
loadingWhether to show the skeleton. `false` renders the default slot instead.
linesNumber of placeholder items; clamped to at least 1.
variantShape variant for each generated placeholder item.
widthWidth; numbers are converted to px
heightHeight; numbers are converted to px
radiusCorner radius for non-circle items; numbers are converted to px.
gapGap between multiple lines; numbers are converted to px

Events

TxSkeleton, TxCardSkeleton, and TxListItemSkeleton do not emit custom events.

Slots

ComponentSlotPropsDescription
TxSkeletondefault-Final content rendered only when loading=false.
TxCardSkeleton--Fixed card placeholder; no slots.
TxListItemSkeleton--Fixed list-row placeholder; no slots.

Preset Components

ExportPurpose
TxSkeleton / SkeletonConfigurable line, rectangle, or circle placeholder.
TxCardSkeleton / CardSkeletonFixed card/feed placeholder with icon, title, badge, and description blocks.
TxListItemSkeleton / ListItemSkeletonFixed list-row placeholder with icon, name, meta, and trailing badge blocks.

Dashboard Data Operations

For table loading, TxDataTable's loadingVariant="skeleton" draws the placeholder rows itself, and a short local wait can keep its default overlay; side summaries beside the table use TxSkeleton to preserve layout rhythm.

Data operations panel

Skeleton placeholders and table loading cover the data-region wait state together.

Loading demo...

Overview

  • loading=false renders the default slot instead of the skeleton.
  • lines always renders at least one item, preventing empty skeleton output.
  • variant="circle" always uses a circular radius and ignores radius.
  • The TxSkeleton root is aria-hidden="true", so the decorative shimmer is not announced. Let the host region own the loading announcement (for example aria-busy or a polite live region), then hand off to real content at loading=false.

Technologies

  • Reviewed against packages/tuffex/packages/components/src/skeleton/src/types.ts, TxSkeleton.vue, TxCardSkeleton.vue, TxListItemSkeleton.vue, and skeleton.test.ts.
  • Existing tests cover CSS-variable emission, numeric-to-px conversion, line count clamping, circle radius normalization, the decorative aria-hidden root, loading=false slot handoff, fixed preset rendering, and install registration.
  • API note: TxSkeleton is the configurable primitive; TxCardSkeleton and TxListItemSkeleton are fixed-shape presets with no props, events, or slots.
  • Rendering note: variant="circle" forces --tx-skeleton-radius: 999px; callers should set matching width and height for a true circle.
  • Component source: packages/tuffex/packages/components/src/skeleton/src/TxSkeleton.vue, TxCardSkeleton.vue, and TxListItemSkeleton.vue.
  • Types: packages/tuffex/packages/components/src/skeleton/src/types.ts exports SkeletonProps and SkeletonVariant.
  • Verified coverage: packages/tuffex/packages/components/src/skeleton/__tests__/skeleton.test.ts verifies CSS variable output, numeric-to-px conversion, line clamping, circle radius, the decorative aria-hidden root, loading=false slot handoff, preset rendering, and install registration.
查看源码
packages/tuffex/packages/components/src/skeleton/index.ts