
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
react-custom-autocomplete
Advanced tools
React component for customizing user input autocomplete - using `contenteditable` div
React Custom Autocomplete
React component for customizing user input autocomplete - using contenteditable div
A flexible and customizable React component that provides a content-editable <div> for user input, ideal for autocomplete and rich text scenarios.
Built using Rslib.
npm i react-custom-autocomplete
import { AutocompleteContentEditable } from "react-content-editable-autocomplete";
const onSelectMenuItem = (item: Menu.Item) =>
console.log("Menu item selected:", item);
const onSearchFruits = (value: string) => {
// Simulate search results
return [
{ label: "Apple", value: "apple", icon: <span>🍎</span> },
{ label: "Banana", value: "banana", icon: <span>🍌</span> },
{ label: "Cherry", value: "cherry", icon: <span>🍒</span> },
// ...
].filter((item) => item.label.toLowerCase().includes(value.toLowerCase()));
};
<AutocompleteContentEditable
onSelectMenuItem={onSelectMenuItem}
placeholder='Search for fruits, start query with "/"'
searchTrigger='/'
style={{
width: "50vw",
background: "white",
}}
onSearch={onSearchFruits}
value=''
/>;
In some cases, you want to apply special styling to the autocompleted terms, or a different HTML tag altogether (i.e. anchor <a> or button <button> tag), that's where using contenteditable div for the underlying textarea comes in handy, it allows for raw HTML (with developer-imposed restrictions in this case to prevent Cross-Site Scripting attack) to be rendered directly inside the textarea div.
Here's an example usage:
import { AutocompleteContentEditable } from "react-content-editable-autocomplete";
import { AutocompleteContentEditable as AutocompleteContentEditableType } from "react-content-editable-autocomplete/dist/types/AutocompleteContentEditable";
const tags = [
{ label: "#Lifestyle", value: "lifestyle" },
{ label: "#Technology", value: "technology" },
// ...
];
const onSearchTags = (value: string) => {
// Simulate search results
return value && value.length > 0
? tags.filter((item) =>
item.label.toLowerCase().includes(value.toLowerCase())
)
: tags;
};
const SelectionCustomization: AutocompleteContentEditableType.SelectionHTMLTag<"i"> =
{
HTMLTag: "i",
HTMLInlineStyle: {
padding: "5px 10px",
fontSize: "12px",
backgroundColor: "#e3edf9",
borderRadius: "16px",
color: "#4d80c5",
},
HTMLClassName: "custom-tag-class",
};
<AutocompleteContentEditable
onSelectMenuItem={onSelectMenuItem}
placeholder='Search for tags, start query with "#"'
searchTrigger='#'
// renderMenuItem={TagMenuItemCustomRendering}
style={{
width: "60vw",
background: "white",
}}
showSelectionAsHTMLTag={SelectionCustomization}
onSearch={onSearchTags}
value=''
/>;
Install the dependencies:
pnpm install
Build the library:
pnpm build
Build the library in watch mode:
pnpm dev
FAQs
React component for customizing user input autocomplete - using `contenteditable` div
We found that react-custom-autocomplete demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.