React hook to detect browser's autofill
A lightweight React hook for detecting autofill events on form inputs in modern browsers. This package provides an easy-to-use API to track autofill status on HTML elements, handle autofill events, and create responsive UI feedback.
- Detects browser autofill using animations, transitions, and input events.
- Provides autofill and autofill cancel events.
- Lightweight and dependency-free.
- Compatible with modern browsers.
Install the package using npm, yarn, pnpm, or bun:
``bash`
npm install detect-autofill-reactor
yarn add detect-autofill-reactor
pnpm add detect-autofill-reactor
bun add detect-autofill-react
Import the hook and use it in your React component:
`tsx
import React, { useRef } from "react";
import { useAutofillDetection } from "detect-autofill-react";
const AutofillExample = () => {
const { isAutofilled } = useAutofillDetection(document);
return (
export default AutofillExample;
`
#### Hook: useAutofillDetection
##### Parameters:
- scope: AutofillScope | null - The scope of the detection (can be a specific HTMLElement or document).
##### Returns:
- isAutofilled: boolean - Indicates whether the form field is autofilled.autofillRef: React.RefObject
-
This package is licensed under the MIT License. See the LICENSE file for details.
Contributions are welcome! Please submit issues and pull requests via GitHub.