Skip to Content
Piplup
@piplup/rhf-adaptersmui-materialComponents

MuiInputElement

Use MUI Input with react-hook-form without writing a Controller. MuiInputElement binds value and validation for the standard-variant input.

Import

import { MuiInputElement } from '@piplup/rhf-adapters/mui-material';

Usage

'use client';import * as React from 'react';import FormControl from '@mui/material/FormControl';import Stack from '@mui/material/Stack';import {  MuiFormHelperTextElement,  MuiInputElement,  MuiFormLabelElement,  MuiButtonElement,} from '@piplup/rhf-adapters/mui-material';import { useForm } from 'react-hook-form';export default function Page() {  const inputId = React.useId();  const helperTextId = `${inputId}-helper-text`;  const { control, handleSubmit } = useForm({ defaultValues: { email: '' } });  return (    <form onSubmit={handleSubmit((values) => alert(JSON.stringify(values, null, 2)))} noValidate>      <Stack direction="column" spacing={2}>        <FormControl variant="outlined">          <MuiFormLabelElement control={control} htmlFor={inputId} name="email">            Email          </MuiFormLabelElement>          <MuiInputElement            aria-describedby={helperTextId}            control={control}            id={inputId}            name="email"            type="email"            required          />          <MuiFormHelperTextElement            control={control}            id={helperTextId}            name="email"            renderOnError          />        </FormControl>        <div>          <MuiButtonElement control={control} type="submit" variant="contained">            Submit          </MuiButtonElement>        </div>      </Stack>    </form>  );}

Props

Prop

Type

MuiInputElement supports props of the MUI Input component, along with additional adapter-specific props. For a complete list of available Input properties, refer to the MUI API documentation.

The ref is forwarded to the underlying <Input /> component.

Notes

  • Use this component for standard MUI input fields managed by RHF.
  • For custom input UIs, build on useMuiInputAdapterProps.

See also

On this page