react-aria hooks useCheckbox with separate label #6083
-
Hello everyone, I have been trying to implement a Checkbox with the <input id="test-input" />
<div />
<label for="test-input" /> Obviously a very simplified example. I want to separate them to have greater freedom in styling. Linking the input and the now separated label was super easy, with the Does react-aria support having the checkbox control separate from the label and if yes, how would I go about getting that setup? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I think this is a case where you'll just want to override typescript. <div {...labelProps as React.HTMLAttributes<HTMLElement>}>...</div>
|
Beta Was this translation helpful? Give feedback.
I think this is a case where you'll just want to override typescript.
labelProps
just contains press handlers fromusePress
, so it should be fine. I would just test your component on a variety of devices, including touch screens and assistive tech, to ensure it still has a good experience. And be sure the input is still labelled viaaria-labelledby
.