Piplup
@piplup/rhf-adaptersmui-materialComponents

MuiInputElement

A pre-integrated MuiInputElement component for connecting MUI Input to React Hook Form.

Import

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

Usage

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

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