-
-
Notifications
You must be signed in to change notification settings - Fork 32.8k
Closed
Labels
RFCRequest For Comments.Request For Comments.package: joy-uiSpecific to Joy UI.Specific to Joy UI.scope: text fieldChanges related to the text field.Changes related to the text field.waiting for 👍Waiting for upvotes. Open for community feedback and needs more interest to be worked on.Waiting for upvotes. Open for community feedback and needs more interest to be worked on.
Description
Problems
The TextField is a wrapper of FormLabel, Input, and FormHelperText. It binds the id with ARIA to those components which reduce a lot of effort for developers.
However, it becomes a pain when you need to pass props to the inner HTML input:
Hard to customize
To pass a prop to the HTML input, you have to do this:
<TextField
componentsProps={{
input: {
componentsProps: {
data-attributes: '',
}
}
}}
/>Confusion
Take Material UI as an example, Joy UI would follow the same regardless of the final APIs for the TextField.
here is some confusion from the community about the API of the TextField:
- [docs] TextField examples have
endAdornmentas a prop, but implementation requires it onInputProps#31421 TextFieldinputPropsnot passed to<input/>#29525- [material-ui][TextField] InputProps vs inputProps confusion #11377
Proposal
Remove the TextField component and lean toward composition similar to Chakra UI.
<FormControl>
<FormLabel>...</FormLabel>
<Input /> {/* This could be Textarea, Select, Autocomplete */}
<FormHelperText>...</FormHelperText>
</FormControl>I think the removal of the TextField will clean up the confusion and hand over the customization to developers which sounds like a good strategy for us (as a maintainer).
Advantages
- I believe that it will reduce the issues related to the props injection for Joy UI.
- Low learning curve because it is one-to-one DOM mapping.
- It is easier to customize both styling and passing props.
- Don't need to spend time thinking about the API that the
TextFieldshould have (currently, thecomponentsPropsdoes not work) - The pattern can be used with
Textarea,Select, andAutocompletewithout creating new field components.
Disadvantages
- More character to type (I don't think this is a big deal because Chakra UI has positive feedback)
- Different experience compare to Material UI (does it matter that much? Material UI also provide
FormControlfor composition as well)
johndatserakis, WilliamKelley, bharatkashyap, BrentonCozby, beytarovski and 3 moreclytras
Metadata
Metadata
Assignees
Labels
RFCRequest For Comments.Request For Comments.package: joy-uiSpecific to Joy UI.Specific to Joy UI.scope: text fieldChanges related to the text field.Changes related to the text field.waiting for 👍Waiting for upvotes. Open for community feedback and needs more interest to be worked on.Waiting for upvotes. Open for community feedback and needs more interest to be worked on.