This content originally appeared on DEV Community and was authored by HarmonyOS
Read the original article:How to use Lottie JSON Animations in HarmonyOS with ArkTS?
Implement lightweight and scalable Lottie animations in your HarmonyOS Next app using ArkTS with full control and best practices.
Introduction
Animation plays a crucial role in making mobile applications feel intuitive, responsive, and polished. But traditional frame-based or image-sequence animations can increase app size and drain system performance.
Enter Lottie — a lightweight animation solution that allows you to export After Effects animations as JSON and render them natively in your HarmonyOS Next app using ArkTS.
In this guide, you’ll learn:
- How yo set up and use Lottie in your HarmonyOS project
- How to play, pause, and control animations
- Best practices for performance and compatibility
- Practical use cases where Lottie excels Let's get started.
Requirements
Before we begin, ensure your development setup includes the following:
- DevEco Studio 4.0 or later
- A valid .json animation file (exported via Bodymovin)
- A properly structured resources/rawfile/ directory
import { LottieComponent, LottieComponentController, LottieResource } from '@ohos/lottie';
Place your .json animation file into the resources/rawfile/ folder:
resources/
└── rawfile/
└── success_animation.json
Example: Play and Stop Animation in ArkTS
Here’s how to integrate and control a Lottie animation in an ArkUI component.
lottie-example.ets
@Entry
@Component
struct LottieExample {
private animationController: LottieComponentController = new LottieComponentController()
build() {
Column({ space: 16 }) {
// Lottie animation container
LottieComponent({
controller: this.animationController,
resource: new LottieResource($rawfile('success_animation.json')),
autoPlay: false,
loop: true
})
.width(200)
.height(200)
}
.alignItems(HorizontalAlign.Center)
.padding(20)
}
}
The LottieComponentController provides several useful methods:
Additional configuration like loop: true or autoPlay: true can be set at the component level.
Tips & Best Practices
- Keep your .json file under 1 MB for optimal performance.
- Use vector-based animations with solid fills; avoid raster images in AE.
- Test on physical devices — some advanced AE features may not render correctly in the previewer.
- Avoid excessive masks, gradients, and 3D effects unless you verify support.
- Use setProgress() if you need to sync animation with external app logic.
Common Use Cases
Lottie animations can be applied to various real-world scenarios:
- Success/failure confirmation animations
- Splash and onboarding screens
- Animated icons or buttons
- Visual transitions between pages or states
- Gamified or playful interactions
Conclusion
HarmonyOS offers a seamless integration path for Lottie animations through ArkTS and the @ohos/lottie module. With just a JSON file and a few lines of code, you can deliver animations that are lightweight, scalable, and delightful to users.
If you’re looking to modernize your app’s interface and create a more engaging user experience, Lottie is an ideal solution — now fully compatible with HarmonyOS.
References
Lottie Files
https://forums.developer.huawei.com/forumPortal/en/topic/0201190278491267090?fid=0102647487706140266
Written by Ali Anil Toklu
This content originally appeared on DEV Community and was authored by HarmonyOS

HarmonyOS | Sciencx (2025-08-21T09:18:33+00:00) How to use Lottie JSON Animations in HarmonyOS with ArkTS?. Retrieved from https://www.scien.cx/2025/08/21/how-to-use-lottie-json-animations-in-harmonyos-with-arkts/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.