import React, { useState } from "react";
export default function App() {
const [show, setShow] = useState(true);
return (
<div>
<button onClick={() => setShow((s) => !s)}>toggle</button>
<div style={{ display: show ? "block" : "none" }}>hello</div>
</div>
);
}
<input type="checkbox" id="toggle" class="offscreen" />
<label for="toggle" class="switch"></label>