-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FormControl][material-next] Add FormControl component #38411
Comments
This comment was marked as outdated.
This comment was marked as outdated.
I've opened this issue as the remaining features for InputBase require the FormControl component As a utility component, it isn't straightforward to customize the features of the FormControl. For example Material UI and Joy UI both have custom properties they need in the context for the design to work. I looked way back into the history of the Base UI FormControl and found this discussion (from 2 yrs ago, in the initial FormControl PR!) that is against merging context, and instead recommends wrapping extra context like this: <FormControl>
<FormControlContext.Provider value={thingsSpecificToMd}>
<FormControlUnstyled>
<FormControlUnstyledContext.Provider value={genericThings}>
<!-- actual form controls --> Should we stick with this approach for Currently the Joy UI form control is pretty much independent of the Base UI one, so it may be the first time trying out this method |
This comment was marked as outdated.
This comment was marked as outdated.
@mj12albert I'm not sure I get the idea. Will Material's import { BaseFormControl } from '@mui/base'
function FormControl(props) {
const { children } = props;
// Here we would redirect props to BaseFormControl
// or Material's context provider accordingly
return (
<FormControlContext.Provider value={mdSpecificState}>
<BaseFormControl {...baseFormControlProps}>
{ children }
</BaseFormControl>
</FormControlContext.Provider>
);
} Is that correct? So, the user would still maintain the same API, but internally, we would use the context providers separately. Adjacent question: does the use of context mean there's no SSR support for FormControl? (as an actual server component) |
Yes that's the idea ~ this looks like the only practical way to make a Material UI form control on top of the Base UI one
There could be some changes but I think it will mostly be the same - what I'm wondering (out loud 😅 ) is whether it will be unnecessarily complicated to use this multiple provider composition instead of just doing it from scratch like Joy UI. At the moment, the Base UI FormControl is relatively simple on the inside (tracking some state in the context). This also leads me to think about how a user is expected to customize/extend the Base UI FormControl – e.g. adding a |
@DiegoAndai SSR should work fine, but currently it's using |
From the Material/Joy user perspective, the key is this comment: "We'd have MD-version of From the Base user perspective (which is us right now 😅), I think using both contexts and joining in the |
Closing this as all the migration checklist tasks are done, previously linked "new features/breaking changes" have been moved to #38374 |
Issue for adding
FormControl
to@mui/material-next
as part of the Material You effort (#29345)Open questions/discussion
onChange
[FormControl] Integrate FormControl with input components base-ui#17Migration Guide checklist
Drop support for ThemeProvider in favor of CssVarsProviderFormControl doesn't consume any tokens[ ] Refactor component to use Base UIthis is more of a new featureImplement Material You design specs- it only contains reset styles and doesn't use any tokensAdd component playground to v5 docswill be done at theTextField
andSelect
levelRefactor styles to use component CSS Variables- it only contains reset styles and doesn't use any tokensTasks
'should not warn when toggling between inputs'
test fromInputBase
, it was dropped in 38392 - [FormControl][material-next] Add FormControl component #39032sizeSmall
class - [FilledInput][material-next] Add FilledInput component #39307 (comment)The text was updated successfully, but these errors were encountered: