Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-mentions

Package Overview
Dependencies
Maintainers
5
Versions
90
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-mentions

React mentions input

  • 4.4.10
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
207K
increased by0.04%
Maintainers
5
Weekly downloads
 
Created

What is react-mentions?

The react-mentions package is a React component that provides @mention functionality for input fields and text areas. It allows users to mention people, hashtags, or any other entities in a text input, and it provides a dropdown list of suggestions as the user types.

What are react-mentions's main functionalities?

Basic Mentions

This feature allows you to mention users in a text input. As you type '@', a dropdown list of users will appear, and you can select a user to mention.

import React from 'react';
import { MentionsInput, Mention } from 'react-mentions';

const users = [
  { id: '1', display: 'John Doe' },
  { id: '2', display: 'Jane Smith' }
];

const App = () => (
  <MentionsInput value="" onChange={(e) => console.log(e.target.value)}>
    <Mention
      trigger="@"
      data={users}
      renderSuggestion={(suggestion, search, highlightedDisplay) => (
        <div>{highlightedDisplay}</div>
      )}
    />
  </MentionsInput>
);

export default App;

Custom Trigger Characters

This feature allows you to use custom trigger characters, such as '#', to mention tags or other entities in a text input.

import React from 'react';
import { MentionsInput, Mention } from 'react-mentions';

const tags = [
  { id: '1', display: 'ReactJS' },
  { id: '2', display: 'JavaScript' }
];

const App = () => (
  <MentionsInput value="" onChange={(e) => console.log(e.target.value)}>
    <Mention
      trigger="#"
      data={tags}
      renderSuggestion={(suggestion, search, highlightedDisplay) => (
        <div>{highlightedDisplay}</div>
      )}
    />
  </MentionsInput>
);

export default App;

Multiple Mention Types

This feature allows you to use multiple mention types within the same input field, such as '@' for users and '#' for tags.

import React from 'react';
import { MentionsInput, Mention } from 'react-mentions';

const users = [
  { id: '1', display: 'John Doe' },
  { id: '2', display: 'Jane Smith' }
];

const tags = [
  { id: '1', display: 'ReactJS' },
  { id: '2', display: 'JavaScript' }
];

const App = () => (
  <MentionsInput value="" onChange={(e) => console.log(e.target.value)}>
    <Mention
      trigger="@"
      data={users}
      renderSuggestion={(suggestion, search, highlightedDisplay) => (
        <div>{highlightedDisplay}</div>
      )}
    />
    <Mention
      trigger="#"
      data={tags}
      renderSuggestion={(suggestion, search, highlightedDisplay) => (
        <div>{highlightedDisplay}</div>
      )}
    />
  </MentionsInput>
);

export default App;

Other packages similar to react-mentions

Keywords

FAQs

Package last updated on 30 Jun 2023

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc