react-spectrum
react-spectrum copied to clipboard
Support HelpText/FieldError for standalone Checkbox, Radio, and Switch
Provide a general summary of the feature here
We will want to support HelpText/FieldError for standalone Checkbox and Radio. Switch should support just HelpText.
๐ค Expected Behavior?
The api should look something like this (naming of the wrapper to be finalized):
<CheckboxField>
<Checkbox>Unsubscribe</Checkbox>
<Text slot="description">Description here.</Text>
<FieldError />
</CheckboxField>
Note that the field error context will need to be set in the wrapper
๐ฏ Current Behavior
HelpText/FieldError isn't supported for any of these components yet
๐ Possible Solution
No response
๐ฆ Context
These are all valid use cases for these components, we just didn't add support for them yet
๐ป Examples
No response
๐งข Your Company/Team
RSP
๐ท Tracking Issue
No response
Hi! i'm looking at this issue because i was thinking of implementing something similar in my design system.
The api should look something like this (naming of the wrapper to be finalized):
<CheckboxField> <Checkbox>Unsubscribe</Checkbox> <Text slot="description">Description here.</Text> <FieldError /> </CheckboxField> ```
In Spectrum and RAC Starter kits, fields are usually wrapped and offer props like description, errorMessage and label. So i imagine the component in RAC Starter kit would look like this.
<CheckboxField
label="Unsubscribe"
description="Description here." />
Would the intention in the starter kit be to completely replace Checkbox, or would the intention be to use Checkbox and CheckboxField as needed, for instance inside a CheckboxGroup?
<CheckboxGroup label="Choices">
<Checkbox>Option 1<Checkbox>
<CheckboxField
label="Option 2"
description="Description of option 2 here." />
<Checkbox>Option 3<Checkbox>
<CheckboxGroup>
Good question, I'd lean towards always having CheckboxField aka completely replace Checkbox in the starter kit. Can't really think of any reasons to have the two separated within the starter kit itself, but if you were just to use RAC as is you'd be able to use Checkbox standalone vs wrapping it in a CheckboxField when needed.
Note that its pretty early days for this HelpText support for these components so the API is still subject to change as the team discusses it some more.
I'm working on something similar too. I think the standalone Checkbox should be used inside CheckboxGroup, which is itself a form field. CheckboxField within CheckboxGroup(Field) would be a little strange I guess. The standalone Checkbox can also be used in other components like Table. So I guess for the starter kit, it still makes sense to have a separate Checkbox.