View as Markdown

API reference: @salmonui/dropdowns/mention

Mentioncomponent

import { Mention } from '@salmonui/dropdowns/mention';
function Mention<T = MentionItem>(props: MentionProps<T>): ReactNode;

Props: MentionProps

Mention props (35)
NameSignatureDescription
childrenoptionalreadonly children?: ReactNode;

One <textarea> or <input> (possibly nested in other markup). Omit it and pass target instead.

targetoptionalreadonly target?: RefObject<HTMLTextAreaElement | HTMLInputElement | null>;

The field to attach to when it is not a child.

editoroptionalreadonly editor?: MentionEditorTarget | null;

A contenteditable surface to attach to instead of a field: the result of createContentEditableMentionTarget(element) or the target a rich text editor provides. Keep it stable across renders; it wins over target and children fields.

dataoptionalreadonly data?: MentionData<T>;

Suggestions for triggers without their own data.

triggersoptionalreadonly triggers?: readonly MentionTrigger<T>[];

Trigger characters, each with optional own data (default [{ char: '@' }]).

requireLeadingSpaceoptionalreadonly requireLeadingSpace?: boolean;

A trigger only counts at the start or after whitespace (default true).

multiWordoptionalreadonly multiWord?: boolean;

The search text may contain spaces.

minSearchLengthoptionalreadonly minSearchLength?: number;

Characters typed after the trigger before the list opens.

maxResultsoptionalreadonly maxResults?: number;

Suggestions shown at most.

searchOperatoroptionalreadonly searchOperator?: MentionSearchOperator<T>;

Default 'contains'.

matchCaseoptionalreadonly matchCase?: boolean;
ignoreAccentsoptionalreadonly ignoreAccents?: boolean;
searchFieldsoptionalreadonly searchFields?: readonly string[];

Fields a remote source searches (default ['label']).

debounceoptionalreadonly debounce?: number;

Delay in ms before a remote read (default 300); local data filters on every keystroke.

highlightMatchesoptionalreadonly highlightMatches?: boolean;

Mark the matched text in each suggestion (<mark>).

getItemValueoptionalreadonly getItemValue?: (item: T) => string | number;
getItemLabeloptionalreadonly getItemLabel?: (item: T) => string;
isItemDisabledoptionalreadonly isItemDisabled?: (item: T) => boolean;
getInsertTextoptionalreadonly getInsertText?: (item: T, trigger: MentionTrigger<T>) => string;

Text inserted for an item (default its label).

onBeforeInsertoptionalreadonly onBeforeInsert?: (event: MentionBeforeInsertEvent<T>) => void;
onInsertoptionalreadonly onInsert?: (event: MentionInsertEvent<T>) => void;
onOpenChangeoptionalreadonly onOpenChange?: (open: boolean, event: MentionOpenChangeEvent) => void;
onSearchChangeoptionalreadonly onSearchChange?: (event: MentionSearchChangeEvent) => void;
onLoadErroroptionalreadonly onLoadError?: (error: unknown) => void;
renderItemoptionalreadonly renderItem?: (context: MentionRenderItemContext<T>) => ReactNode;
renderEmptyoptionalreadonly renderEmpty?: () => ReactNode;
renderLoadingoptionalreadonly renderLoading?: () => ReactNode;
renderErroroptionalreadonly renderError?: (context: { readonly error: unknown; }) => ReactNode;
localeTextoptionalreadonly localeText?: Partial<MentionLocaleText>;
containeroptionalreadonly container?: Element | null;

Portal container of the popup (default the field's closest theme scope, else document.body).

classNameoptionalreadonly className?: string;
styleoptionalreadonly style?: CSSProperties;
classNamesoptionalreadonly classNames?: Partial<Record<MentionPart, string>>;
stylesoptionalreadonly styles?: Partial<Record<MentionPart, CSSProperties>>;
refoptionalreadonly ref?: Ref<HTMLDivElement>;

The root <div> that wraps children.