
Security News
Node.js Drops Bug Bounty Rewards After Funding Dries Up
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.
react-switch-theme
Advanced tools
Switch between your themes easily, uses react hooks. Just provide the colors object for themes and switch it. switch between light or dark theme, or so.
Switch between your themes, (i.e. dark/light or so) with just one click. Uses react hooks. react-switch-theme on npm
npm i react-switch-theme
This does not break anything, old usage is still valid.
import { ThemeProvider, Theme } from "react-switch-theme";
const colors = {
light: {
background: "#fff",
color: "#000"
},
dark: {
background: "#000",
color: "#fff"
}
};
const activeMode = "light";
const offlineStorageKey = "react-random-key";
// wrap your app
<ThemeProvider
colors={colors}
activeMode={activeMode}
offlineStorageKey={offlineStorageKey}
>
<App />
</ThemeProvider>
const [theme, toogleTheme] = useContext(Theme);
theme is current theme: string, toogleTheme is a function which changes your current theme.
4. Access your css var from css-in-js or css:
// You did the hardwork now just use your vars.
background: var(--background);
color: var(--color);
Import ( default import ):
import useReactSwitchTheme from 'react-switch-theme';
Pass one option to the hook
const options = {
colors: {
// Object of two color objects. light and dark or whatever you call them.
light: {
// These properties will be converted to css vars
// These can be named anything
// You can access them in css, css-in-js or in other way by using 'var(--propName)'
background: '#fff',
color: '#000',
},
dark: {
// Property name must be same for both objects
background: '#000',
color: '#fff',
},
},
// This is the current active theme
// It must be one of the key of colors object
activeMode: 'light',
// An unique key for your app to store themeMode in localStorage
// It should be same for every load.
// So, choosen theme stays even after a refresh
offlineStorageKey: 'replace it with you app name or some hash'
}
Use it in your app:
const [currentMode, setDiffMode] = useReactSwitchTheme(options)
// currentMode is a string with the currentTheme as value
// light or dark here.
// setDiffMode is function which will toggle between two themes on call.
Your css:
// You did the hardwork now just use your vars.
background: var(--background);
color: var(--color);
FAQs
Switch between your themes easily, uses react hooks. Just provide the colors object for themes and switch it. switch between light or dark theme, or so.
We found that react-switch-theme 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
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.