# React Mentions TS React Mentions TS is a React component library that enables Facebook/Twitter-style @mentions and tagging functionality in textarea inputs with full TypeScript support. The library provides a flexible, accessible, and customizable solution for implementing mention-based interactions in web applications. The component handles the complex task of managing mentions within text input by maintaining two parallel representations: the user-facing plain text display and an internal markup format that preserves mention metadata. It supports multiple trigger patterns (like @ for users, # for tags), both synchronous and asynchronous data sources, custom rendering, and sophisticated keyboard navigation with full ARIA accessibility support. ## Basic Usage Basic implementation with static user data ```tsx import React, { useState } from 'react' import { MentionsInput, Mention } from 'react-mentions-ts' function App() { const [value, setValue] = useState('') const users = [ { id: 'johndoe', display: 'John Doe' }, { id: 'janedoe', display: 'Jane Doe' }, { id: 'alice', display: 'Alice Smith' } ] const handleChange = (event, newValue, newPlainTextValue, mentions) => { setValue(newValue) console.log('Markup value:', newValue) console.log('Plain text:', newPlainTextValue) console.log('Mentions:', mentions) } return ( ) } // Markup value: "Hi @[John Doe](johndoe), how are you?" // Plain text: "Hi John Doe, how are you?" // Mentions: [{ id: 'johndoe', display: 'John Doe', index: 3, plainTextIndex: 3, childIndex: 0 }] ``` ## Single Line Input Creating a single-line mention input instead of textarea ```tsx import React, { useState } from 'react' import { MentionsInput, Mention } from 'react-mentions-ts' function SingleLineExample() { const [value, setValue] = useState('') const data = [ { id: 'user1', display: 'User One' }, { id: 'user2', display: 'User Two' } ] return ( setValue(newValue)} placeholder="Mention people using '@'" > ) } // Renders an element instead of