New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

light-dark-toggle

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

light-dark-toggle

A custom element for toggling dark mode

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

LightDarkToggle

Dark mode using the browser

How to use?

import { LightDarkToggle } from 'light-dark-toggle';

LightDarkToggle.define();

How does it work?

When the toggle renders in your HTML, using <light-dark-toggle> it renders a button with the current mode inside of it and a <meta> with the name color-scheme and the content set to the preferred color scheme of the user.

TODO

  • Use a <meta name="color-scheme"> in the <head> as the source of truth if it exists.
  • Detect and handle multiple instances
  • Accept a toggle in the light dom instead of overriding the innerHTML of the light-dark-toggle element.
  • Reflect preference in localstorage
  • Tests?
  • Performance?

Keywords

web components

FAQs

Package last updated on 21 May 2024

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