Masked Input

React masked input that formats phone numbers, dates, plates and IBANs as you type from a mask, keeps the caret steady on edits and pastes, and returns masked and raw values.

src/registry/ui/masked-input.tsx/r/masked-input.json

Installation#

bash
npx shadcn@latest add https://ui.minidev.pro/r/masked-input.json

Usage#

tsx
import { MaskedInput } from "@/components/ui/masked-input"

export function Example() {
  return <MaskedInput />
}

API reference#

MaskedInput props
PropTypeDefault
maskstring-
labelReact.ReactNode-
valuestring-
defaultValuestring""
onChange(value: MaskedValue) => void-
guideboolean | stringtrue
guideCharstring"_"
uppercasebooleanfalse
placeholderstring-
hintReact.ReactNode-
showCompletebooleantrue
showRawbooleantrue
invalidbooleanfalse
disabledbooleanfalse
requiredbooleanfalse
idstring-
namestring-
autoCompletestring"off"
inputModeReact.HTMLAttributes<HTMLInputElement>["inputMode"]-
examplesMaskedInputExample[]EXAMPLES
classNamestring-

Dependencies#

npm

lucide-react

Built from

All form components