[RFC] Form Components Refactor
See original GitHub issueHi all! 👋 Wanted to take a stab at suggesting some Form-related improvements we could make for Carbon X. These don’t represent anything that we’d need to commit to, just are suggestions for where we could take some of these components in the future. Curious what you all thing 😄
For Forms, I figured we could focus initially on some of the wrappers around some of the more primitive input types. These could include text inputs, Checkbox & Radio, Textarea, etc. The way we could improve some of these is by introducing the following types on top of these inputs:
- Inline input component (
InlineCheckbox
)- These would be wrappers around the input itself, and for associating a label to it. They would not be wrapped in a form item, and would be ideal for incorporating an input inside of another component. For example, checkboxes for selection in a DataTable
- These components would support forwarding refs to the underlying
<input>
- Input component (
Checkbox
)- Similar to what we have now, but would be a stateless variant that would be wrapped in a form item. Would forward refs to underlying
<input>
node - Also should support the render logic for displaying validation state, but not handling the validations themselves
- Similar to what we have now, but would be a stateless variant that would be wrapped in a form item. Would forward refs to underlying
- Controlled input component (
ControlledCheckbox
)- Would control the underlying stateless inputs and provide an
onChange
hook for folks to register. Also could provide avalidate
method, as well, to help folks hook in and show validation status
- Would control the underlying stateless inputs and provide an
Looking forward, consumers would use these alongside our existing Form
or FormGroup
components. We could also, down the line, provide aliases for popular form libraries if we wanted to help out more with this use-case.
Anyways, that’s it! Curious to hear what everyone thinks 😄
Issue Analytics
- State:
- Created 5 years ago
- Comments:11 (7 by maintainers)
Top GitHub Comments
@joshblack Thank you for more background. I see your point. My comments wrt the controlled version is more for caution given the history of our project getting numerous issues against our controlled components, and a suggestion that getting out of that business will be easier for us considering our maintenance effort, and for consumers by eliminating potential confusions.
As there’s been no activity since this issue was marked as stale, we are auto-closing it.