Categories: CSSScriptWeb Design

Floating Autocomplete Box For Textarea – floatype.js

floatype.js is a lightweight and fast JavaScript library that adds autocomplete/autosuggestion functionality to textareas.

As soon as you start typing characters into a textarea, the library automatically displays a floating dropdown box next to the cursor with preset suggestions to choose from.

See Also:

How to use it:

1. Install and import the floatype.js library.

# NPM
$ npm i @knadh/floatype
// ES module
import { floatype } from @knadh/floatype;
// Browser
<script type="module">
  import { floatype } from './floatype.js';
</script>

2. Define an array of suggestions as follows:

const myData = ["CSS", "Script", "Com"];

3. Initialize the floatype.js on your textarea element and enable the autocomplete functionality using the onQuery.

floatype(document.querySelector("textarea"), {
  onQuery: async (val) => {
  // This callback returns an array of search results.
  // Typically, this will be a server side fetch() request.
  // Example:
  //    const resp = await fetch(`/search?q=${query}`);
  //    const res = await response.json();
  //    return res;
  const q = val.trim().toLowerCase();
  return myData.filter(s => s.startsWith(q)).slice(0, 10);
  }
});

4. Apply your own CSS styles to the autocomplete list.

.floatype {
  /* styles here */}

.floatype-item {
  /* styles here */}

.floatype-item:hover {
  /* styles here */}

.floatype-sel {
  /* styles here */}

Changelog:

v1.2.2 (04/30/2025)

  • Bugfixes

The post Floating Autocomplete Box For Textarea – floatype.js appeared first on CSS Script.

rssfeeds-admin

Share
Published by
rssfeeds-admin

Recent Posts

Why Investors Are Betting Billions On Low Earth Orbit Satellites

The post Why Investors Are Betting Billions On Low Earth Orbit Satellites appeared first on…

15 minutes ago

Advanced Systems Group Names Kevin Poole Senior Project & Support Manager For Workflow & Tools Practice

Kevin Poole Advanced Systems Group, a technology and services provider for media creatives and content…

16 minutes ago

NAB Show: Utah Scientific To Showcase Hybrid SDI/IP Innovations

Utah Scientific said it will spotlight its expanding portfolio of hybrid SDI/IP routing, conversion, control…

16 minutes ago

NAB Show: Miri To Introduce V410 Live 4K Encoder/Decoder

Miri Technologies’ V410 live 4K encoder/decoder will make its North American debut at the NAB…

16 minutes ago

NAB Show: Net Insight Unveiling JPEG XS For Live IP Media Production

Net Insight is introducing a full IP JPEG XS solution at NAB Show in Las…

16 minutes ago

NAB Show: FOR-A To Showcase Software-Defined, AI-Powered Workflows At NAB 2026

FOR-A Corp., will showcase its latest software-defined, AI-powered workflow at NAB Show in Las Vegas,…

16 minutes ago

This website uses cookies.