Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

use-prefers-color-scheme

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

use-prefers-color-scheme

React hook for determining the preferred color scheme

  • 1.1.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
13K
increased by9.96%
Maintainers
1
Weekly downloads
 
Created
Source

use-prefers-color-scheme

React hook for determining the preferred color scheme

NPM JavaScript Style Guide

Features:

  • SSR support
  • Written in Typescript

Install

npm install --save use-prefers-color-scheme

Usage

Tip When rendered in node (SSR) the hook returns no-preference.

import React from 'react'

import usePrefersColorScheme from 'use-prefers-color-scheme'

const App = () => {
  const prefersColorScheme = usePrefersColorScheme()
  const isDarkMode = prefersColorScheme === 'dark'

  return (
    <div>You are using {isDarkMode ? 'Dark Mode 🌚' : 'Light Mode 🌞'}!</div>
  )
}

Online Demo

Open Codesanbox

License

MIT © rfoel

FAQs

Package last updated on 31 Jan 2023

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc