suiss/ui · Component
Skeleton
A pulsing placeholder block that stands in for content while it loads.
Skeleton is an open-source component from suiss/ui for React, React Native, SwiftUI and Jetpack Compose. The @esuiss/ui CLI copies its source into your project, so you own the code.
Skeleton is a plain div with a pulsing animation, rounded corners and a muted fill. It has no size of its own; set width, height and shape with utility classes so each placeholder matches the content it replaces.
Combine several skeletons to sketch a layout, such as an avatar with two lines of text. For an indeterminate activity indicator, use Spinner instead.
Installation
Works in any project with a components.json. See Installation for the one-line registry setup. Or use the suiss/ui CLI:
-
Add the
cnhelper. -
Copy and paste the following code into your project.
- Update the import paths to match your project setup.
Usage
Examples
Profile
Sketches an avatar beside two lines of text. The avatar uses rounded-full to override the default rounded-md.
Card
Sketches a media card with an image and two lines of text.
List
Sketches a list of rows, each with an icon and two lines of text.
Accessibility
Skeletonrenders an emptydivwith no role or text, so it isn't announced. Let assistive technologies know content is loading another way, for example witharia-busyon the region that's loading.
API Reference
Skeleton
A pulsing placeholder block.
Also accepts the props of React.ComponentProps<"div">.
Size every skeleton with classes such as h-4 w-48. The skeleton sets data-slot="skeleton" and uses the animate-pulse animation.
Web preview
Skeleton is a Reanimated View with a rounded background whose opacity pulses between 1 and 0.5 on a loop. It has no fixed size; you shape it with classes to match the content it stands in for.
Installation
- Install the following dependencies:
- Copy and paste the following code into
components/ui/skeleton.tsx:
- Update the import paths to match your project setup.
- Install the following dependencies:
- Copy and paste the following code into
components/ui/skeleton.tsx:
- Update the import paths to match your project setup.
- Install the following dependencies:
- Copy and paste the following code into
components/ui/skeleton.tsx:
- Update the import paths to match your project setup.
-
Target iOS 17 or later.
-
Copy the theme files every view uses:
- Copy the source:
- Add the files to your app target.
- Apply the Compose compiler plugin, enable Compose, set
compileSdkto 37 or higher andminSdkto 24 or higher, and add the dependencies:
- Copy the theme files every view uses:
- Copy the source and every file it uses:
- Update the
com.esuiss.uipackage names to match your project.
Usage
Examples
Profile
An avatar circle with two lines of text.
Web preview
Card
A media block with two lines of text below it.
Web preview
List
Rows with a thumbnail and two lines of text.
Web preview
Accessibility
- The skeleton is a plain view with no role or label. If loading state matters to the user, announce it elsewhere, for example with a
Spinnerthat has anaccessibilityLabel.
API Reference
Skeleton
A pulsing placeholder block.
Also accepts the props of React.ComponentProps<typeof View>, React.RefAttributes<View>.
Set width, height and radius through className, for example h-4 w-48 for a line of text or size-12 rounded-full for an avatar. Compose several skeletons to mirror the layout of the loaded content, then swap them for the real content once it arrives. The pulse runs on the UI thread through Reanimated, with a 1000 ms cycle.
Skeleton
A pulsing placeholder block.
| Parameter | Type | Default |
|---|---|---|
cornerRadius | CGFloat | Radius.md |
Skeleton
A pulsing placeholder block.
| Parameter | Type | Default |
|---|---|---|
modifier | Modifier | Modifier |
shape | Shape | RoundedCornerShape(Radius.md) |