dark-mode-ts
TypeScript icon, indicating that this package has built-in type declarations

1.2.6 • Public • Published

dark-mode-ts

Npm package total Npm package version Npm package license Npm package daily downloads Npm package daily downloads

NOTE:

dark-mode-ts based on TypeScript, "react": "^18.2.0" and "react-dom": "^18.2.0".

Works with React, React TypeScript, React Vite, React Vite TypeScript.

The user setting persists to localStorage.

dark-mode-ts:

  • a minimal lightweight component for your React projects
  • quickly setup
  • has a small bundle size and zero dependencies
  • you have total control with styles - css, scss, sass, tailwind ui.

Like it, it GitHub

import React from 'react';
import {Theme} from "dark-mode-ts";
import yourDarkImage from './path/to/your/DarkImage.png'
import yourLightImage from './path/to/your/LightImage.png'

const NameYourComponent = () => {
  return (
    <div>
      <Theme
        darkIcon={yourDarkImage}
        lightIcon={yourLightImage}
        altDark='dark icon'
        altLight="light icon"
        imgWidth='50'
        imgHeight='50'
        myClass="your-class_name"
      />
    </div>
  )
};

A React theme component accepts the following props:

Key Type Description
darkIcon string Work with .png, .jpg, .svg* extensions.
lightIcon string Work with .png, .jpg, .svg* extensions.
altDark string For better accessibility.
altLight string For better accessibility.
imgWidth string Width for your icon.
imgHeight string Height for your icon.
myClass string If you want to have background or add hover effect for icon wrapper.

* - Don't forget, svg has width and height by default.

Add your global styles. Example:

:root {
  --background-color: #007aff;
  --color-text: white;
}

[data-theme='light'] {
  --background-color: #227d2c;
  --color-text: black
}

body {
  background: var(--background-color);
  color: var(--color-text);
}

Installation

$ npm i dark-mode-ts

Package Sidebar

Install

npm i dark-mode-ts

Weekly Downloads

8

Version

1.2.6

License

MIT

Unpacked Size

13.9 kB

Total Files

9

Last publish

Collaborators

  • craziestbee