Socket
Socket
Sign inDemoInstall

rc-mentions

Package Overview
Dependencies
Maintainers
3
Versions
69
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rc-mentions

React Mentions


Version published
Weekly downloads
1.3M
decreased by-2.39%
Maintainers
3
Weekly downloads
 
Created

What is rc-mentions?

The rc-mentions npm package is designed to provide a React component for implementing mention features within applications. It allows users to easily mention people, tags, or other entities in text inputs or textareas by typing a trigger character (like '@') followed by a list of suggestions.

What are rc-mentions's main functionalities?

Basic Mentioning

This feature allows for basic mentioning functionality where users can type '@' followed by a list of predefined suggestions. The code sample demonstrates how to set up a basic Mention component with a default value and a list of suggestions.

import React from 'react';
import Mention from 'rc-mentions';
const { Option } = Mention;

function App() {
  return (
    <Mention
      style={{ width: '100%' }}
      defaultValue="@afc163"
      suggestions={['afc163', 'benjycui', 'yiminghe', 'RaoHai', '中文', 'にほんご']}
    />
  );
}

Custom Trigger

This feature allows users to customize the trigger character for mentions. In this example, both '@' and '#' are set as triggers, enabling mentions for users as well as tags or other entities.

import React from 'react';
import Mention from 'rc-mentions';
const { Option } = Mention;

function App() {
  return (
    <Mention
      style={{ width: '100%' }}
      prefix={['@', '#']}
      suggestions={['afc163', 'benjycui', 'yiminghe', 'RaoHai', '中文', 'にほんご']}
    />
  );
}

Custom Render

This feature allows for custom rendering of suggestions. The code sample shows how to use the Option component to customize how suggestions are displayed, providing more flexibility in the presentation of suggestions.

import React from 'react';
import Mention from 'rc-mentions';
const { Option } = Mention;

function App() {
  return (
    <Mention
      style={{ width: '100%' }}
      suggestions={['afc163', 'benjycui', 'yiminghe', 'RaoHai', '中文', 'にほんご'].map(value => (
        <Option key={value} value={value}>
          {value}
        </Option>
      ))}
    />
  );
}

Other packages similar to rc-mentions

Keywords

FAQs

Package last updated on 22 Nov 2022

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