Skeleton
Moti's skeleton component is great for showing animated loading states. It works on all platforms, including web.
Example#
Install#
Expo Users#
You'll also want to install expo-linear-gradient.
Please note that you must have Reanimated 3 installed. See installation steps for more info.
Non-Expo users#
If you aren't using Expo, you can either use the expo-linear-gradient package, or react-native-linear-gradient.
Option 1: expo-linear-gradient#
- npm
- Yarn
Keep in mind you'll need to also install expo-modules-core. Please make sure you complete any installation steps required for Expo's linear gradient component.
Option 2: react-native-linear-gradient#
Click here to use react-native-linear-gradient
First, install the module resolver plugin:
Next, add this to your app's babel.config.js's plugins array.
This assumes you've installed react-native-linear-gradient and followed any of its installation requirements.
Your skeletons will now use react-native-linear-gradient. You can continue importing from moti/skeleton.
Video#
Usage#
Show/hide#
Skeleton will hide when data exists by default.
You can always show the skeleton:
Or hide it:
Border radius#
Use radius to show a circle, square, or custom border radius. Defaults to 8.
Circle#
Square#
Custom radius#
Color modes#
light or dark
Custom animation delay#
Custom animation transition#
Full example#
Here's the code from the video above:
<Skeleton.Group />#
If you have many skeleton components, you can now wrap them with a single <Skeleton.Group show={loading} /> component. This will help you achieve this type of effect.