Skip to main content

Skeleton Loading

npm version npm downloads GitHub source code Contributions welcome npm unpacked size language npm last update npm license

The @flexnative/skeleton-loading package is a specialized UI component for React Native applications. Its primary purpose is to provide skeleton screens—placeholder versions of your user interface that appear while content is still loading.

Installation

You can installing Skeleton Loading packages using npm:

npm i @flexnative/skeleton-loading

API

import SkeletonLoader from '@flexnative/skeleton-loading';

Features

Based on its configuration, here are the key aspects of the package:

  • User Experience (UX): It improves perceived performance by showing a visual representation of the layout (like gray boxes or lines where text and images will eventually be) instead of a blank screen or a simple spinner.
  • SVG-Powered Animations: Unlike some skeleton loaders that rely on standard views, this package utilizes SVG animations (via react-native-svg). This often allows for more complex, performant, and fluid "shimmer" effects.
  • Theme Integration: It is built to work seamlessly with the @flexnative/theme-context, meaning it can automatically adapt its colors and styles to match your application's light or dark themes.
  • Performance: It is described as "performance-optimized," which is crucial for loading states to ensure that the placeholder itself doesn't lag the device while the app fetches data in the background.

Properties

info

IContentLoaderProps props extends SvgProps so any SvgProps properties are also applicable in IContentLoaderProps

NameTypeRequiredDefault ValueDescription
animatebooleanfalsetrueDetermines whether the skeleton loading components should be animated.
backgroundColorColorValuefalseundefinedThe background color of the skeleton placeholder.
foregroundColorColorValuefalseundefinedThe foreground (highlight) color used for the animation effect.
speednumberfalse1.2The animation speed factor.
intervalnumberfalse0.25The interval between animation cycles.
uniqueKeystringfalserandom stringA unique identifier used for internal SVG elements (like Rect fill and clipPath) to avoid ID collisions.
beforeMaskReact.ReactElementfalseundefinedA React element to be rendered as a mask on the loading indicator.

Playground

Live Editor
//Play with props to see live changes;

render(
  <SkeletonLoader width={'100%'} height={110} animate={true} backgroundColor='crimson' foregroundColor='#FFC436'>
    <Rect x="48" y="8" rx="3" ry="3" width="88" height="10" />
    <Rect x="48" y="26" rx="3" ry="3" width="52" height="6" />
    <Rect x="0" y="56" rx="3" ry="3" width="100%" height="6" />
    <Rect x="0" y="72" rx="3" ry="3" width="100%" height="6" />
    <Rect x="0" y="88" rx="3" ry="3" width="178" height="6" />
    <Circle cx="20" cy="20" r="20" />
  </SkeletonLoader>
);
Result
Loading...