Custom CSS & HTML Toggle Switch Help #1909
-
Beta Was this translation helpful? Give feedback.
Answered by
Fil
Jan 22, 2025
Replies: 2 comments 1 reply
-
Hello, you were almost there: what was missing was to send a custom input event after the element's value changes, to inform the reactivity downstream. In more details: https://observablehq.observablehq.cloud/pangea/support/toggle-switch |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
GatsbyFitz
-
Another option using React: const clicked = Mutable(true);
function toggleClicked() {
clicked.value = !clicked.value;
} function Counter({ clicked }) {
return (
<label class="switch">
<input type="checkbox" onChange={toggleClicked} checked={clicked.value} />
<span class="slider round"></span>
</label>
);
} display(<Counter clicked={clicked} />); |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello,
you were almost there: what was missing was to send a custom input event after the element's value changes, to inform the reactivity downstream.
In more details: https://observablehq.observablehq.cloud/pangea/support/toggle-switch