Skip to content

Instantly share code, notes, and snippets.

@gladchinda
Created May 4, 2020 18:26
Show Gist options
  • Save gladchinda/47db8285b28ef7424eea38fbdfbc6c7d to your computer and use it in GitHub Desktop.
Save gladchinda/47db8285b28ef7424eea38fbdfbc6c7d to your computer and use it in GitHub Desktop.
import React from 'react';
import { Sun, Moon } from 'react-feather';
export default function DarkModeToggleSwitch ({ on, toggle }) {
const props = {
type: 'button',
role: 'switch',
onClick: (typeof toggle === 'function') ? toggle : () => {},
'aria-checked': (on = on === true)
};
return <button {...props}>{ on ? <Sun /> : <Moon /> }</button>
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment