Loading...
Loading...
Implement the Syncfusion React Mention (MentionComponent) for @-tagging users or items inside editable content areas. Use this when adding @mention or
npx skill4agent add syncfusion/react-ui-components-skills syncfusion-react-mentionMentionComponent<div contenteditable>@@syncfusion/ej2-react-dropdownsMentionComponenttargetmentionCharshowMentionChar⚠️ Security Note: Installing npm packages (and related) must be a deliberate, user-confirmed step. Do not allow automated agents to run@syncfusion/ej2-react-dropdownswithout explicit user approval, as this introduces supply-chain risk.npm install
fieldsODataV4AdaptorWebApiAdaptorqueryminLengthContainsStartsWithEndsWithallowSpacessuggestionCountdebounceDelayitemTemplatedisplayTemplatenoRecordsTemplatespinnerTemplategroupTemplateshowMentionCharsuffixTextpopupHeightpopupWidthmentionCharrequireLeadingSpacecssClasshighlightignoreAccentignoreCasezIndexAscendingDescendingNonefields.disableddisableItem()aria-selectedaria-activedescendentaria-ownsenableRtlnoRecordsTemplateL10nlocaletargetdataSourcefieldsmentionCharminLengthsuggestionCountaddItemdisableItemgetDataByValuegetItemsshowPopuphidePopupsearchdestroyselectchangefilteringbeforeOpenopenedcloseddataBoundactionBeginactionCompleteactionFailureimport { MentionComponent } from '@syncfusion/ej2-react-dropdowns';
import * as React from 'react';
// CSS imports
// @import "../node_modules/@syncfusion/ej2-base/styles/tailwind3.css";
// @import "../node_modules/@syncfusion/ej2-react-dropdowns/styles/tailwind3.css";
function App() {
const mentionTarget = '#commentBox';
const users = [
{ Name: 'Selma Rose', EmailId: 'selma@example.com' },
{ Name: 'Robert', EmailId: 'robert@example.com' },
{ Name: 'William', EmailId: 'william@example.com' },
];
const fields = { text: 'Name' };
return (
<div>
<label>Comments</label>
<div id="commentBox" placeholder="Type @ to mention a user"></div>
<MentionComponent
target={mentionTarget}
dataSource={users}
fields={fields}
/>
</div>
);
}
export default App;mentionChar#@<MentionComponent
target="#editor"
dataSource={tags}
mentionChar="#"
showMentionChar={true}
/>import { DataManager, ODataV4Adaptor, Query } from '@syncfusion/ej2-data';
// NOTE: Replace the URL below with your own API endpoint.
// Do not use third-party or public endpoints in production.
const dataSource = new DataManager({
url: 'https://your-api-endpoint.example.com/odata/',
adaptor: new ODataV4Adaptor,
crossDomain: true,
});
const query = new Query().from('Customers').select(['ContactName', 'CustomerID']).take(6);
const fields = { text: 'ContactName', value: 'CustomerID' };
<MentionComponent
target="#editor"
dataSource={dataSource}
fields={fields}
query={query}
minLength={2}
popupWidth="250px"
/>import { SelectEventArgs } from '@syncfusion/ej2-react-dropdowns';
function onSelect(args: SelectEventArgs) {
console.log('Selected item:', args.itemData);
console.log('Selected text:', args.text);
}
<MentionComponent
target="#editor"
dataSource={users}
fields={{ text: 'Name' }}
select={onSelect}
/><MentionComponent
target="#editor"
dataSource={data}
fields={{ text: 'Name' }}
popupHeight="200px"
popupWidth="300px"
suggestionCount={10}
sortOrder="Ascending"
suffixText=" "
/>| Prop | Type | Default | Purpose |
|---|---|---|---|
| | — | CSS selector or element for the editable area |
| | | Data for suggestions |
| | | Maps data fields |
| | | Trigger character |
| | | Prepend trigger char to inserted text |
| | | Min chars before search |
| | | Max items in popup |
| | | Filter match strategy |
| | | Allow spaces in search |
| | | Sort direction |
| | | Popup height |
| | | Popup width |
| | | Text appended after selection |
| | | Space required before trigger char |
| | | Highlight search characters |