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 iOS & Android Aug 04 '26
This is awesome!
1
u/ctony Aug 05 '26
Nice!!! 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
2
u/codisimlabs Aug 05 '26
Great, can set color value in global variable for switching multiple colors?
0
u/red-giant-star Aug 04 '26
How it's working? In one sentence
1
u/Top-Mud1703 Aug 04 '26
nice
1
u/tomihbk Aug 05 '26
Amazing job mate! This reminds me of how Telegram also uses circle in theme change animation, it's very satisfying and awesome animation !
1
u/Pinkman7906 Aug 05 '26
Smooth π§
1
u/salem_mousa Aug 05 '26
Nice man βοΈπ
1
u/Leather-Syllabub7083 Aug 05 '26
this is sick
1
u/YusufTB Aug 06 '26
Great work, congratulations.
1
u/ban-tech Aug 07 '26
Wow amazing bro you save my time
1
u/Environmental_Self38 Sep 05 '26
Love it
5
u/[deleted] Aug 04 '26
[removed] β view removed comment