Tangible Design System · @tangible/ui 0.2.61 · Interactive version · Markdown

Skeleton

import { Skeleton, useDelayedLoading } from '@tangible/ui';

Interactive docs and examples: Skeleton in Storybook.

Skeleton props

Prop Type Default Description
lines? number 1 Text only: how many lines. The last of several is shorter.
shape? "block" | "circle" | "text" 'text' - `text`: lines of text, each one line-height tall (the default); `circle`: an avatar-sized circle, sized by `size`; `block`: media, a chart or a tile; 16:9 unless sized with `style`
size? "lg" | "md" | "sm" | "xl" | "xs" | "xxl" Circle only: Avatar's size scale. Unset, it is the md size (2.5rem).
textStyle? SkeletonTextStyle Text only: size the lines to a text style. Without it, the lines take the surrounding font size and line height.

Also accepts the standard attributes of HTMLAttributes (data-*, aria-*, event handlers), passed to the element it renders.

Skeleton.Region

Also exported as SkeletonRegion.

Prop Type Default Description
loading boolean Whether the content is loading.
children? ReactNode The loaded content. On a first load it isn't rendered until loading ends (it may have no data yet); once shown, it stays up until the fallback replaces it.
delay? number 300 How long loading must last before the fallback shows, in ms. A faster load shows nothing and swaps once.
fallback? ReactNode Shown in place of the content while loading: compose Skeletons in the real layout. Without one, the region is still busy and announces, but shows nothing while loading.
loadedLabel? string Announced when content arrives, only after loadingLabel was announced ("Courses loaded"). Ignored without loadingLabel.
loadingLabel? string Announced politely once loading has lasted past delay ("Loading courses"). Nothing is announced for a fast load. Named as Button's: it is spoken, it doesn't name the region.
minDuration? number 500 Once shown, the fallback stays at least this long, in ms, so content doesn't replace it a frame later.
stale? boolean false Keep showing the current content while loading (a refetch). The region is marked busy and no fallback shows: swapping loaded content for grey bars on every refresh is a regression, not a loading state.

Also accepts the standard attributes of HTMLAttributes (data-*, aria-*, event handlers), passed to the element it renders.

Hooks

useDelayedLoading

useDelayedLoading(loading: boolean, { delay, minDuration }?: DelayedLoadingOptions): boolean

Examples

Other stories: Default, Paragraph, Text Styles, In Card, In List Row, In a stat tile, Surfaces, Dashboard, Dashboard: loaded and loading, Region, Region: focus on reload, useDelayedLoading (interactive page).

Component API tokens

Read via fallback, never declared. Set one on an ancestor to restyle every instance under it.