RIFM (React Input Format & Mask) is a tiny (~800 bytes, gzipped) library that provides both a component and a hook to transform any input component into a formatted or masked input. Current stable version is 0.12.1. It requires React 16.8+, has zero dependencies, and ships with TypeScript definitions. Unlike larger alternatives like react-number-format or react-input-mask, RIFM is minimal and focused on cursor-position preservation after formatting. It supports any input component (e.g., Material-UI, custom) and can handle number formatting, date masking, and case enforcement. Release cadence is low; updates are infrequent but stable.
npm install rifmNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates using the useRifm hook with a number formatter that adds locale thousands separators.
If you rely on the old behavior (only digits accepted), pass accept=/\d/g explicitly.
Migrate to using 'format' function that returns the formatted string directly.
Test your format functions thoroughly. Ensure the format function preserves 'accepted' character order as per the documentation.
Keep format functions simple and memoize if needed with React.useCallback.
Ensure React >=16.8 is installed and use named import: import { useRifm } from 'rifm'Run: npm install rifm or yarn add rifm. Then import correctly: import { Rifm } from 'rifm'Change import to: import { Rifm } from 'rifm'