Skeleton
Token placeholder shimmer with reduced-motion, background and viewport pause.
npx @swipeui/cli add skeletonWhen to use it
- Placeholders while a feed, profile or card loads, shaped like the content to come.
- Avoiding layout jumps by reserving space for text and images.
- Text lines, circles for avatars and rectangles for media.
When not to use it
- Very quick loads under half a second; it adds flicker.
- Actions that are processing. Use a button's loading state.
- Empty results. Use Empty state.
Installation
Run this from your app's root. If SwipeUI isn't set up yet, run npx @swipeui/cli init first; it sets up Uniwind, the theme tokens and the cn helper.
npx @swipeui/cli add skeleton- Adds
components/swipeui/ui/skeleton.tsxand 4 shared helpers. - Installs react-native-reanimated, react-native-worklets, uniwind, clsx, tailwind-merge. In Expo apps it uses
npx expo installso versions match your SDK.
Usage
import { Skeleton } from '@/components/swipeui/ui/skeleton';
<Skeleton height={24} />;Examples
Use the variant and appearance controls in the live specimen to compare the documented states. The application owns validation, operation results and persistence.
API reference
SkeletonProps
| Prop | Type | Default | Description |
|---|---|---|---|
width? | | — | Intrinsic placeholder width; otherwise fills its parent. |
height? | | | Intrinsic placeholder height. |
variant? | | | Shape. |
active? | | | Caller viewability/navigation override. |
motion? | | — | Shared ambient feel. |
className? | | — | Root classes. |
style? | | — | Native layout escape hatch. |
testID? | | — | Root ID. |
Native view/input props not listed here pass through where the exported TypeScript type allows them.
Composition and behavior
- variant is rectangle, circle or text; width and height set the size.
- active pauses the shimmer, for example when a screen isn't focused.
Feedback lineup settings
| Prop | Does / default |
|---|---|
width | Intrinsic placeholder width; otherwise fills its parent. |
height | Intrinsic placeholder height. @default 16 |
variant | Shape. @default 'rectangle' |
active | Caller viewability/navigation override. @default true |
motion | Shared ambient feel. |
className | Root classes. |
style | Native layout escape hatch. |
testID | Root ID. |
preset | Content layout. @default 'profile' |
appearance | Optional card surface. @default 'elevated' |
label | Spoken loading purpose. @default 'Loading content' |
The loading recipes match the finished shared specimens: a named designer profile with a naturally wrapping, fuller work bio and founder-supplied Instagram, LinkedIn and X logos; a creator feed with host-supplied music-player art; full-name collaborators with distinct roles; and weekly activity with a rising trend and animated goal progress. These are specimen contents, not data or assets shipped by the Skeleton primitive.
The feed keeps the whole supplied image inside an explicit 2:1 rounded frame on both hosts. Like fills vivid red, Save fills sky blue and Repost highlights green; Comment shows a “Comment clicked” pill toast. These local interactions demonstrate finished content without changing Skeleton loading behavior.
Behavior and gestures
- Static; a soft shimmer sweeps across while it's on screen.
- The shimmer pauses when it scrolls off screen, the app goes to the background or active is false.
Accessibility
- Hidden from screen readers; announce loading separately if needed, for example with a Spinner label.
- Reduce Motion removes the shimmer and shows a still placeholder.
Motion
- Uses the
ambientmotion role, so it follows your app's feel. Passmotionto tune this one instance. - The sweep uses the ambient role.
- Reduce Motion turns it off.
Performance
- The shimmer stops when not visible, so long lists of skeletons stay light.
Notes for AI
- Match the real layout's sizes so nothing jumps when content arrives.
Compatibility
| Runs on | Supported |
|---|---|
| Expo SDK 57 | Yes |
| Expo SDK 58 | Yes |
| React Native CLI (with Expo modules) | Yes |
| Expo Go | Yes |
| iOS | Yes |
| Android | Yes |
This table describes API support and static bundle checks. Native runtime, device accessibility and bare Uniwind compatibility remain pending.