Ready-made controllers
Text fields, selects, autocomplete, checkboxes, switches, radio groups, and date pickers — each aligned with MUI props and RHF’s control.
MUI v9 · React Hook Form · TypeScript
A focused set of controllers and a
FormFields
helper so you ship validated, accessible inputs faster — without re-wiring RHF on every project.
Less boilerplate between MUI and React Hook Form
Text fields, selects, autocomplete, checkboxes, switches, radio groups, and date pickers — each aligned with MUI props and RHF’s control.
Describe fields as data — names, types, grid layout, and props — and render a whole form region from one component.
Pair with Yup or Zod resolvers, Emotion, and MUI’s layout primitives. MIT licensed and built for real apps.
Install from npm alongside your MUI, Emotion, and React Hook Form peer dependencies.
pnpm
pnpm add mui-rhf-library
npm
npm install mui-rhf-library
yarn
yarn add mui-rhf-library
Controllers and FormFields types
Everything maps to familiar MUI components and React Hook Form’s control object.
Import and place next to your form logic.
Used in each entry of the FormFields fields array.
Doing it by hand means repeating Controller wrappers, default values, error messages, and ref forwarding for every MUI input variant. mui-rhf-library centralizes those patterns so you keep using MUI’s documented props and RHF’s control—without rewriting the same glue for each new form.
Controllers or data-driven FormFields
Drop-in MUI controllers, or describe fields in an array and render them with FormFields.
Individual controllers
import { TextFieldController, SelectController } from 'mui-rhf-library';
import { useForm } from 'react-hook-form';
type ExampleFormValues = {
name: string;
role: string;
};
export function Example() {
const { control } = useForm<ExampleFormValues>({
defaultValues: { name: '', role: '' },
});
return (
<>
<TextFieldController
control={control}
name="name"
defaultValue=""
label="Full name"
/>
<SelectController
name="role"
label="Role"
control={control}
options={[
{ label: 'Admin', value: 'admin' },
{ label: 'Editor', value: 'editor' },
]}
/>
</>
);
}
FormFields from a config array
import { FormFields, type FieldProps } from 'mui-rhf-library';
import { useForm } from 'react-hook-form';
import { yupResolver } from '@hookform/resolvers/yup';
import Grid from '@mui/material/Grid';
import * as yup from 'yup';
type SignupFormValues = {
firstName: string;
lastName: string;
acceptTerms: boolean;
};
const signupSchema = yup
.object({
firstName: yup.string().required('First name is required'),
lastName: yup.string().required('Last name is required'),
acceptTerms: yup
.boolean()
.oneOf([true], 'You must accept the terms'),
})
.required();
export function SignupForm() {
const { control, handleSubmit } = useForm<SignupFormValues>({
defaultValues: { firstName: '', lastName: '', acceptTerms: false },
resolver: yupResolver(signupSchema),
});
const fields: FieldProps[] = [
{
fieldType: 'textField',
name: 'firstName',
label: 'First name',
props: { fullWidth: true },
gridProps: { size: { xs: 12, sm: 6 } },
},
{
fieldType: 'textField',
name: 'lastName',
label: 'Last name',
props: { fullWidth: true },
gridProps: { size: { xs: 12, sm: 6 } },
},
{
fieldType: 'checkbox',
name: 'acceptTerms',
label: 'I accept the terms',
gridProps: { size: { xs: 12 } },
},
];
return (
<form
onSubmit={handleSubmit((data: SignupFormValues) => {
console.log(data);
})}
>
<Grid container spacing={2}>
<FormFields fields={fields} control={control} />
</Grid>
<button type="submit">Submit</button>
</form>
);
}
Full API tables and migration notes live in the repository README .