Piplup
@piplup/rhf-adaptersreact-number-formatComponents

NumericFormatElement

A pre-integrated NumericFormatElement component for formatted numeric input with React Hook Form.

Import

import { NumericFormatElement } from "@piplup/rhf-adapters/react-number-format";

Usage

"use client";import Stack from '@mui/material/Stack';import { NumericFormatElement } from "@piplup/rhf-adapters/react-number-format";import { MuiButtonElement } from "@piplup/rhf-adapters/mui-material";import { useForm } from "react-hook-form";export default function Page() {  const { control, handleSubmit } = useForm({    defaultValues: { price: "1200" },  });  return (    <form      onSubmit={handleSubmit((values) =>        alert(JSON.stringify(values, null, 2)),      )}    >      <Stack direction="column" spacing={2}>        <NumericFormatElement control={control} name="price" thousandSeparator prefix="$" />        <div>          <MuiButtonElement control={control} type="submit" variant="contained">            Submit          </MuiButtonElement>        </div>      </Stack>    </form>  );}
"use client";import Stack from "@mui/material/Stack";import { NumericFormatElement } from "@piplup/rhf-adapters/react-number-format";import { MuiButtonElement } from "@piplup/rhf-adapters/mui-material";import { FormContainer } from "@piplup/rhf-core";export default function Page() {  return (    <FormContainer      defaultValues={{ price: "1200" }}      onSubmit={(values) => alert(JSON.stringify(values, null, 2))}    >      <Stack direction="column" spacing={2}>        <NumericFormatElement name="price" thousandSeparator prefix="$" />        <div>          <MuiButtonElement type="submit" variant="contained">            Submit          </MuiButtonElement>        </div>      </Stack>    </FormContainer>  );}

Props

Prop

Type

NumericFormatElement supports all standard props of the NumericFormat component, along with additional adapter-specific props.

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

Notes

  • Use this component when numeric display formatting should stay separate from stored react-hook-form values.
  • For custom numeric format inputs, build on useNumericFormatAdapter.

On this page