0
0
mirror of https://github.com/yude-jp/yude.jp synced 2025-01-03 18:10:12 +09:00
yude.jp/pages/components/toggle.js

23 lines
483 B
JavaScript

import React from 'react'
import ThemeContext from './themeContext'
const Toggle = () => {
const { theme, setTheme } = React.useContext(ThemeContext)
function isDark() {
return theme === "dark"
}
return (
<label>
<input
type="checkbox"
checked={isDark()}
onChange={e => setTheme(e.target.checked ? "dark" : "light")}
></input>
ダーク モード
</label>
)
}
export default Toggle