Skip to content

Instantly share code, notes, and snippets.

@ChristianOConnor
Created January 17, 2023 23:28
Show Gist options
  • Save ChristianOConnor/3b680ade37af2e6fcfed6917e4885c74 to your computer and use it in GitHub Desktop.
Save ChristianOConnor/3b680ade37af2e6fcfed6917e4885c74 to your computer and use it in GitHub Desktop.
import React, { Dispatch, SetStateAction } from "react";
import "./ToggleSwitch.css";
function ToggleSwitch({ toggledVal, setToggled } : { toggledVal: boolean, setToggled: Dispatch<SetStateAction<boolean>> }) {
const onToggle = () => setToggled(!toggledVal);
return (
<label className="toggle-switch">
<input type="checkbox" checked={toggledVal} onChange={onToggle} />
<span className="switch" />
</label>
);
}
export default ToggleSwitch;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment