Turn off Autocomplete for Input in React

In this short article, we are going to learn how to disable autocomplete of an input field in React. Let’s see:

Table of Contents

  1. Disable in Specefic Input
  2. Disable in Entire Form

Disable in Specefic Input

To disable autocomplete for a specific input field, we need to set autoComplete attribute to off. Example:

import React from "react";

export default function App() {
  return (
    <div theClassName="App">
      <input type="text" autoComplete="off"/>
    </div>
  );
}

Disable in Entire Form

To disable autocomplete for an entire form, we need to set autoComplete attribute with off value in the form like this:

import React from "react";

export default function App() {
  return (
    <div theClassName="App">
      <form autoComplete="off">
         <input type="text"/>
      </form>
    </div>
  );
}

That’s it. Thanks for reading.