Skip to content

Heydon/react-theme-switch

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
src
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

React Theme Switch

A small, self-contained, and accessible component for inverting the theme of React-based interfaces. Uses progressive enhancement to provide a button which flips the theme's colors only where filter: invert(100%) is supported. Local storage persists the mode across browsing sessions.

Install

npm i react-theme-switch

Import

import ThemeSwitch from 'react-theme-switch';

Include

<ThemeSwitch />

Props

Just one optional prop is provided: preserveRasters. By default, raster images (images without the SVG extension, as well as videos) get inverted. To preserve them (through reinversion) use the preserveRasters Boolean.

<ThemeSwitch preserveRasters />

Accessibility

The switch is provided as a screen reader and keyboard accessible <button> element and toggles the aria-expanded state.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published