Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial toggle component #50

Open
moharnadreza opened this issue Apr 9, 2020 · 1 comment
Open

Initial toggle component #50

moharnadreza opened this issue Apr 9, 2020 · 1 comment

Comments

@moharnadreza
Copy link

moharnadreza commented Apr 9, 2020

Hi @donavon, Is it OK to add an initial toggle component? If the answer is yes I'll be happy to work on it.

@philippbck
Copy link

for everybody who has missed a toggle component. I have simply used the react-toggle-component.

npm install react-toggle-component styled-components

And then my dark mode component looks like the following:

import useDarkMode from 'use-dark-mode'
import { Toggle } from 'react-toggle-component'

const DarkModeToggle = () => {
  const darkMode = useDarkMode(false);

  return (
    <div>
      <span role="img" aria-label="sun">🔆</span>
      <Toggle 
        leftBackgroundColor="#ffffff"
        rightBackgroundColor="#1a1919"
        borderColor="black"
        knobColor="#006aff"
        name="toggle-switch"
        checked={darkMode.value} 
        onChange={darkMode.toggle} 
      />
      <span role="img" aria-label="moon">🌙</span>
    </div>
  );
};

export default DarkModeToggle;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants