Skeleton
Moti's skeleton component is great for showing animated loading states. It works on all platforms, including web.
#
Example#
Install#
Expo UsersYou'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 usersIf you aren't using Expo, you can either use the expo-linear-gradient
package, or react-native-linear-gradient
.
expo-linear-gradient
#
Option 1: - 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.
react-native-linear-gradient
#
Option 2: 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/hideSkeleton will hide when data exists by default.
You can always show
the skeleton:
Or hide it:
#
Border radiusUse radius
to show a circle, square, or custom border radius. Defaults to 8
.
#
Circle#
Square#
Custom radius#
Color modeslight
or dark
#
Custom animation delay#
Custom animation transition#
Full exampleHere'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.