Created
June 18, 2021 02:55
-
-
Save anied/d8d8ed838210e5ed9c9c9bc4e6468b9e to your computer and use it in GitHub Desktop.
Example of a custom checkbox with _no_ consideration for proper accessibility.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| .hide { | |
| display: none; | |
| } | |
| .checkbox-wrapper { | |
| display: flex; | |
| } | |
| #custom-subscribe { | |
| display: inline-block; | |
| border: 1px solid black; | |
| height: 1rem; | |
| width: 1rem; | |
| margin-left: 0.5rem; | |
| display: flex; | |
| align-items: center; | |
| justify-content: center; | |
| } | |
| #custom-subscribe-checkmark { | |
| color: green; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <div class="checkbox-wrapper"> | |
| <span id="custom-subscribe-label">Subscribe to custom newsletter</span> | |
| <span id="custom-subscribe"> | |
| <span id="custom-subscribe-checkmark" class="hide">✔</span> | |
| </span> | |
| </div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const checkbox = document.querySelector("#custom-subscribe"); | |
| const checkmark = document.querySelector("#custom-subscribe-checkmark"); | |
| function toggleCustomSubscribe() { | |
| checkmark.classList.toggle("hide"); | |
| } | |
| checkbox.addEventListener("click", toggleCustomSubscribe); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment