
Security News
New CVE Forecasting Tool Predicts 47,000 Disclosures in 2025
CVEForecast.org uses machine learning to project a record-breaking surge in vulnerability disclosures in 2025.
react-themer.js
Advanced tools
Automatically switch between dark and light themes at sunset and sunrise using the user's location.
Spice up your app with themes. Themer.js features include:
prefers-color-scheme
# using yarn
$ yarn add react-themer.js
# using npm
$ npm install react-themer.js
import React, { Component } from "react";
import Themer from "react-themer.js";
const themes = {
light: {
"--app-background-color": "#f1f1f1",
"--primary-text-color": "#555"
},
dark: {
"--app-background-color": "#242835",
"--primary-text-color": "#f1f1f1"
}
}
export default class App extends Component {
render() {
return (
<main style="
background-color: var(--app-background-color);
color: var(--primary-text-color);
">
<Themer active="auto" themes={themes} />
</main>
)
}
}
# index.js
import React, { Component } from "react";
import Themer from "react-themer.js";
import light from "./light.json";
import dark from "./dark.json";
import './index.css';
export default class App extends Component {
state = {
active: "auto",
themes: { dark, light }
};
render() {
const { active, themes } = this.state;
const Button = (theme, name) => {
return (
<button onClick={() => this.setState({ active: theme })}>
{name}
</button>
);
};
return (
<main>
<Themer active={active} themes={themes} />
{Button("auto", "Auto")}
{Button("system", "System")}
{Button(light, "Light")}
{Button(dark, "Dark")}
</main>
)
}
}
# index.css
main {
background-color: --app-background-color;
color: --primary-text-color;
}
# light.json
{
"styles": {
"--app-background-color": "#f1f1f1",
"--primary-text-color": "#555",
}
}
# dark.json
{
"styles": {
"--app-background-color": "#242835",
"--primary-text-color": "#f1f1f1",
}
}
Prop | Type | Description |
---|---|---|
active | string or object | The active theme. |
themes | object | Available themes. |
{
"styles": {
"--app-background-color": "#242835",
"--primary-text-color": "#f1f1f1",
"--primary-accent-color": "#056fb6",
"--primary-link-color": "var(--primary-accent-color)",
"--header-background-color": "#2d303c",
"--button-border-color": "#464d5f",
"--button-background-color": "#393e4d",
"--button-text-color": "#f1f1f1",
"--button-active-border-color": "var(--primary-accent-color)",
"--table-pre-background-color": "#3a3b46",
"--table-zebra-background-color": "rgba(255, 255, 255, 0.04)",
"--code-background-color": "rgba(255, 255, 255, 0.1)"
},
"android": "#242835"
}
Note: The android
key is used to set the meta theme-color.
FAQs
Automatically switch between dark and light themes at sunset and sunrise using the user's location.
The npm package react-themer.js receives a total of 0 weekly downloads. As such, react-themer.js popularity was classified as not popular.
We found that react-themer.js 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
CVEForecast.org uses machine learning to project a record-breaking surge in vulnerability disclosures in 2025.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.