JumboForm

JumboForm is the @jumbo bridge between React Hook Form and MUI input components. It sets up an RHF FormProvider context and optionally wires in a Zod schema via zodResolver. All Jumbo* field components read from this context automatically.

Import

typescript
import {
  JumboForm,
  JumboInput,
  JumboOutlinedInput,
  JumboCheckbox,
  JumboSelect,
} from '@jumbo/vendors/react-hook-form';

JumboForm

Props

PropTypeRequiredDescription
onSuccess(data: T) => voidYesCalled with validated form data on submit
validationSchemaZodSchemaNoZod schema; wired via zodResolver automatically
defaultValuesDefaultValues<T>NoRHF default values
childrenReactNodeYesForm fields and submit button

Usage

tsx
// src/components/LoginForm/LoginForm.tsx
import { JumboForm, JumboInput } from '@jumbo/vendors/react-hook-form';
import { Button } from '@mui/material';
import { z } from 'zod';
 
const loginSchema = z.object({
  email: z.string().email('Enter a valid email'),
  password: z.string().min(6, 'Password must be at least 6 characters'),
});
 
type LoginInput = z.infer<typeof loginSchema>;
 
export function LoginForm() {
  const { login } = useAuth();
 
  const handleSuccess = async (data: LoginInput) => {
    await login(data);
  };
 
  return (
    <JumboForm<LoginInput>
      onSuccess={handleSuccess}
      validationSchema={loginSchema}
      defaultValues={{ email: '', password: '' }}
    >
      <JumboInput
        name='email'
        label='Email address'
        type='email'
        fullWidth
        sx={{ mb: 2 }}
      />
      <JumboInput
        name='password'
        label='Password'
        type='password'
        fullWidth
        sx={{ mb: 3 }}
      />
      <Button type='submit' variant='contained' fullWidth>
        Sign in
      </Button>
    </JumboForm>
  );
}

JumboInput

MUI TextField bound to RHF. Displays inline validation errors automatically.

Props

PropTypeRequiredDescription
namestringYesRHF field name; must match a key in the schema
labelstringNoInput label
typestringNoHTML input type (text, email, password, etc.)
All MUI TextField propsNoPassed through to the underlying TextField

JumboOutlinedInput

Same as JumboInput but renders a OutlinedInput variant with an explicit InputLabel.

JumboCheckbox

MUI Checkbox + FormControlLabel bound to RHF.

Props

PropTypeRequiredDescription
namestringYesRHF field name
labelstring | ReactNodeYesCheckbox label
All MUI FormControlLabel propsNoPassed through

JumboSelect

MUI Select + InputLabel + FormControl bound to RHF.

Props

PropTypeRequiredDescription
namestringYesRHF field name
labelstringYesSelect label
options{ value: unknown; label: string }[]YesOptions to render as MenuItem elements
All MUI FormControl propsNoPassed through

Accessing RHF methods directly

JumboForm renders an RHF FormProvider. Use useFormContext() inside any child to access watch, setValue, formState, etc.:

tsx
import { useFormContext } from 'react-hook-form';
 
function PasswordStrengthMeter() {
  const { watch } = useFormContext<LoginInput>();
  const password = watch('password');
  return <StrengthBar value={password} />;
}