
Security News
Software Engineering Daily Podcast: Feross on AI, Open Source, and Supply Chain Risk
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.
react-native-theme-switch-animation
Advanced tools
A Plug & Play Animations for Switching (Dark/Light) Themes. 🌖
A Plug & Play Animations for Switching (Dark/Light) themes. 🌗
npm install react-native-theme-switch-animation
OR
yarn add react-native-theme-switch-animation
(if you are using expo managed project, do a prebuild - npx expo prebuild)
npx pod-install
import switchTheme from 'react-native-theme-switch-animation';
export default function Example() {
const [theme, setTheme] = React.useState('light');
return (
<Button
title="Switch Theme"
onPress={() => {
switchTheme({
switchThemeFunction: () => {
setTheme(theme === 'light' ? 'dark' : 'light'); // your switch theme function
},
animationConfig: {
type: 'fade',
duration: 900,
},
});
}}
/>
);
}
Circular Example
switchTheme({
switchThemeFunction: () => {
setTheme(theme === 'light' ? 'dark' : 'light'); // your switch theme function
},
animationConfig: {
type: 'circular',
duration: 900,
startingPoint: {
cxRatio: 0.5,
cyRatio: 0.5
}
},
});
| Name | Type | Description |
|---|---|---|
switchThemeFunction | () => void | Adds the function you use in your app to switch themes, doesn't matter if you use redux/context/zustand/mobx or any other way |
animationConfig | AnimationConfig | Configuration for the animation -> type, duration, starting point (default is 'fade' with 500ms duration) |
| Name | Type | Description |
|---|---|---|
type | fade circular inverted-circular | Specifies animation type |
duration | number | Specifies duration in milliseconds |
startingPoint | StartingPointConfig | Configuration for the circular animation, where does the animation start in the screen |
| Name | Type | Description |
|---|---|---|
cx | number | Specifies starting x point for circular and inverted-circular animation (should not exceed your screen width) |
cy | number | Specifies starting y point for circular and inverted-circular animation (should not exceed your screen height) |
cxRatio | number | Specifies starting percentage of x point for circular and inverted-circular animation (should be number between -1 and 1) |
cyRatio | number | Specifies starting percentage of y point for circular and inverted-circular animation (should be number between -1 and 1) |
If you would like the circular animation to start from/to a button/view on your ui automatically, you can do the following
import switchTheme from 'react-native-theme-switch-animation';
<TouchableOpacity
onPress={(e) => {
e.currentTarget.measure((x1, y1, width, height, px, py) => {
switchTheme({
switchThemeFunction: () => {
setTheme(theme === 'light' ? 'dark' : 'light');
},
animationConfig: {
type: 'circular',
duration: 900,
startingPoint: {
cy: py + height / 2,
cx: px + width / 2,
}
},
});
});
}}
/>
MIT
FAQs
A Plug & Play Animations for Switching (Dark/Light) Themes. 🌖
The npm package react-native-theme-switch-animation receives a total of 833 weekly downloads. As such, react-native-theme-switch-animation popularity was classified as not popular.
We found that react-native-theme-switch-animation demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.

Security News
GitHub has revoked npm classic tokens for publishing; maintainers must migrate, but OpenJS warns OIDC trusted publishing still has risky gaps for critical projects.

Security News
Rust’s crates.io team is advancing an RFC to add a Security tab that surfaces RustSec vulnerability and unsoundness advisories directly on crate pages.