Offer suggestions while someone types

A Google AI Mode example shows suggestions in a free-form question field. Explore the difference between choosing, submitting and continuing to type.

SERP Alert · Google AI Mode · Source post

Show suggestions while keeping free text input

An independent web example inspired by the original reference.

Type “signup” and choose a suggestion, or search for any word you like.

Implementation steps

  1. Keep suggestions short enough that choosing one moves the user forward. The sample provides three search examples.
  2. Link the search input to a datalist via the list attribute. Leave native suggestion display and Japanese IME input to the browser.
  3. Separate selecting a suggestion from running the search. Pass whatever value is in the input at submit time to the search target.

Acceptance check

Free-text input can be submitted too. Don't design it so input is allowed only when it matches a suggestion.

View sample code
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Show suggestions while keeping free text input</title>
<style>
  * { box-sizing: border-box; }
  body {
    margin: 0;
    padding: 16px;
    background: #23232a;
    color: #f4f0ea;
    font: 16px/1.6 system-ui, sans-serif;
  }
  label, output, strong, audio, progress { display: block; margin: 6px 0; }
  input, select, button { max-width: 100%; font: inherit; }
  input, select { padding: 4px 7px; }
  button {
    margin: 4px 0;
    padding: 5px 12px;
    cursor: pointer;
    border: 1px solid #b5a399;
    border-radius: 6px;
  }
  :focus-visible { outline: 3px solid #ffad73; outline-offset: 2px; }
  audio { width: 100%; }
  [hidden] { display: none !important; }

</style>
</head>
<body>
<form id="finder">
  <label>Search <input id="query" type="search" list="choices" required></label>
  <datalist id="choices">
    <option value="Shorten signup forms"></option>
    <option value="Improve signup follow-up"></option>
    <option value="Keep a search history"></option>
  </datalist>
  <button>Search</button>
</form>
<output id="result"></output>
<script>
document.querySelector('#finder').onsubmit = event => {
  event.preventDefault();
  const query = document.querySelector('#query').value.trim();
  document.querySelector('#result').textContent = query ? 'Search for: ' + query : 'Enter a search term';
};
</script>
</body>
</html>

Save as index.html and open in a browser to run it locally.

Compare visual changes on your screenAll patterns