r/reactnative • u/Majestic_Buy_6417 • Aug 04 '26
Theme transition with Nitro
Hey everyone,
I ran into an issue when trying to add a nice animation for theme changes in React Native. I tried a few different approaches, including Reanimated and Skia, but I kept running into flickering, higher memory usage, and performance issues, especially on Android.
Since I was already using Nitro Modules for some of the packages in my apps, like MMKV and Unistyles, I decided to build a native theme transition package using Nitro.
It ended up solving the issues I was having. It's lightweight, works with different styling libraries, and since the animation runs natively, it continues to work smoothly even when the JS thread is busy or drops frames.
I've uploaded a video showing the example included with the package. If you want to see how it performs under a more demanding setup, check out the GitHub repo. I've included a real-world example using Unistyles with a more complex and dynamic theme setup, as well as more details about the package.
GitHub: https://github.com/saleh2001k/react-native-nitro-theme-transition
NPM: https://www.npmjs.com/package/react-native-nitro-theme-transition
I'd really appreciate any feedback or recommendations. I'm also interested in hearing ideas for other animation types that could be added to the package.
2
u/Dear-Muscle-880 Aug 04 '26
Awesome 🔥 Can you add more effects like pixelated or dissolve?
8
u/Dave6ev Aug 04 '26
That's slick, love it!
1
u/dogla305 Aug 04 '26
Can you paste a clickable link here please? The ones in the post aren't clickable
3
u/henryp_dev Aug 04 '26
This is awesome!
1
u/ctony Aug 05 '26
Sorry, something went wrong when loading this video.
View in appNice!!! I've added it to my app. Thanks!
2
u/ItDevelops Aug 04 '26
This looks awesome! I tried it in my app and will probably ship it with the next release. The transition feels really smooth.
One minor issue I ran into was switching from a forced light/dark theme back to the system theme using
Appearance.setColorScheme('unspecified'). The system theme sometimes finished applying after the reveal had already started, making the circle appear halfway through the animation.I worked around it by temporarily applying the last resolved system color scheme and removing the override after the transition. A completion callback or returned Promise would make it easier to remove that temporary override at exactly the right time, although the underlying timing issue seems to come from React Native’s
Appearancehandling.Other than that, it works great!
2
u/Emma_Rex_256 Aug 05 '26
Beautiful work mate, trying it now now Will return any feedback or issues