Skip to content

Checkboxes with no children #1555

Answered by richbachman
vankhoawin asked this question in Q&A
Discussion options

You must be logged in to vote

Hey @vnguyen94. The problem with allowing a checkbox to have optional children is accessibility. An accessible text label is a hard requirement for checkboxes.

Luckily, we do have a way a to accomplish what you're after with Paste. You can use the ScreenReaderOnly component as the Checkbox children. This checks-off the accessibility requirement, as well as hiding the text to all but screen readers. Here's a quick example: https://codesandbox.io/s/busy-frog-cm7dc?file=/src/index.tsx

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@vankhoawin
Comment options

@richbachman
Comment options

@vankhoawin
Comment options

Answer selected by vankhoawin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants