Socket
Socket
Sign inDemoInstall

svelte-color-mode

Package Overview
Dependencies
0
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    svelte-color-mode

SSR-compatible, flash-free Svelte components for defining and switching between different color modes.


Version published
Weekly downloads
0
Maintainers
1
Created
Weekly downloads
 

Readme

Source

Svelte Color Mode

Svelte Color Mode

NPM version Netlify Status pre-commit.ci status

Live Demo

SSR-compatible, flash-free, localStorage-persisted color mode + multiple Svelte UI components for selecting current color mode.

Installation

yarn add -D svelte-color-mode

Usage

In a SvelteKit project:

<script>
  import { ColorMode, ColorPicker } from 'svelte-color-mode'

  const colorsByMode = {
    light: {
      textColor: `black`,
      linkColor: 'darkblue',
      hoverColor: 'darkorange',
      bodyBg: `white`,
    },
    dark: {
      textColor: `white`,
      linkColor: 'cornflowerblue',
      hoverColor: 'orange',
      bodyBg: '#061725',
    },
  }
</script>

<ColorMode {colorsByMode} />

For more docs, check out the live demo.

Want to contribute?

At present, svelte-color-mode contains just a few UI components for changing the color mode, all under src/lib/*ColorPicker.svelte. More are welcome. If you have a good idea for a color mode UI and would like to contribute it, please do! Implementation-wise, all it takes is to import the colorMode store (see stores.ts) and change its value based on user input.

To submit a PR, clone the repo, install dependencies and start the dev server to try out your changes.

git clone https://github.com/janosh/svelte-color-mode
cd svelte-color-mode
yarn
yarn dev

Examples

Used in production on these sites:

Keywords

FAQs

Last updated on 08 Jan 2022

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc