react-spectrum icon indicating copy to clipboard operation
react-spectrum copied to clipboard

Support HelpText/FieldError for standalone Checkbox, Radio, and Switch

Open LFDanLu opened this issue 1 year ago โ€ข 3 comments

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

LFDanLu avatar Apr 11 '24 22:04 LFDanLu

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>

alexasselin008 avatar Apr 19 '24 15:04 alexasselin008

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.

LFDanLu avatar Apr 19 '24 17:04 LFDanLu

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.

universse avatar Apr 20 '24 13:04 universse