Socket
Book a DemoInstallSign in
Socket

@fe.whnhouse/use-system-mode

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@fe.whnhouse/use-system-mode

A React Hook to determine system mode (light / dark)

1.0.3
latest
Source
npmnpm
Version published
Maintainers
1
Created
Source

use-system-mode

This React Hook allows you to determine your system´s current Appearance Theme. It uses the CSS Feature MatchMedia to determine if dark mode is enabled or not.

Browser Support

Data on support for the matchmedia feature across the major browsers from caniuse.com

Features

The library exposes two different hooks:

useSystemMode() allows you to get a reactive variable which contains either the value light or dark, depending on the selected theme.

useIsDarkMode() gives you a boolean variable which determines whether dark mode is enabled or not.

Usage

const App = () => {
    const systemMode = useSystemMode()
    return (
        <div>
            <h1>System Mode: {systemMode}</h1>
        </div>
    )
}
const App = () => {
    const darkMode = useIsDarkMode()
    return (
        <div>
            {darkMode ? <h1>Dark Mode</h1> : <h1>Light Mode</h1>}
        </div>
    )
}

Keywords

react

FAQs

Package last updated on 21 Mar 2020

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.