For AI agents: the complete documentation index is available at https://ifhover.github.io/leaf-ui/v/0.6.0/en/llms.txt, the full documentation bundle is available at https://ifhover.github.io/leaf-ui/v/0.6.0/en/llms-full.txt, and this page is available as Markdown at https://ifhover.github.io/leaf-ui/v/0.6.0/en/components/mentions.md.
  • English
  • Mentions

    Insert people or references into text.

    Basic usage

    basic.tsx
    import { Mentions } from '@ifhover/leaf-ui';
    
    export function MentionsBasic() {
      return (
        <Mentions
          aria-label={'Comment'}
          placeholder={'Type @ to mention a teammate'}
          options={[
            { value: 'ada', label: 'Ada' },
            { value: 'lin', label: 'Lin' },
            { value: 'morgan', label: 'Morgan', disabled: true },
          ]}
        />
      );
    }
    

    Different prefixes

    basic.tsx
    import { Mentions } from '@ifhover/leaf-ui';
    
    export function MentionsPrefixes() {
      return (
        <Mentions
          prefixes={['@', '#']}
          aria-label={'Project note'}
          placeholder={'Use @ or # to insert a reference'}
          options={[
            { value: 'design', label: 'Design' },
            { value: 'engineering', label: 'Engineering' },
          ]}
        />
      );
    }
    

    MentionOption

    PropertyTypeDefaultDescription
    valuestring—Required. Controlled value.
    labelReactNode—Visible label or content.
    searchLabelstring—Plain text used for searching.
    disabledboolean—Disable interaction.

    Mentions API

    PropertyTypeDefaultDescription
    size'sm' | 'md' | 'lg'—Presentation size.
    status'error' | 'warning'—Configure status.
    resize'none' | 'vertical' | 'both'—Configure resize.
    autoSizeboolean | TextareaAutoSize—Configure auto size.
    showCountboolean | ((value: string, maxLength?: number) => ReactNode)—Configure show count.
    popupPlacement'top' | 'top-start' | 'top-end' | 'bottom' | 'bottom-start' | 'bottom-end' | 'left' | 'left-start' | 'left-end' | 'right' | 'right-start' | 'right-end'—Placement relative to the trigger.
    popupClassNamestring—Custom class for the popup.
    popupStyleCSSProperties—Custom popup styles.
    popupRender(content: React.ReactNode) => React.ReactNode—Wrap or extend popup content; retain the supplied content to preserve interaction.
    getPopupContainer() => Element | DocumentFragment—Return a popup container, including a ShadowRoot.
    valuestring—Controlled value.
    defaultValuestring''Initial value; uncontrolled fields support native form reset.
    onChange(value: string) => void—Called when the value changes.
    onSearch(query: string, prefix: string) => void—Called when the search text changes.
    onSelect(option: MentionOption, prefix: string) => void—Called when an item is selected.
    optionsreadonly MentionOption[]—Required. Available options.
    prefixesreadonly string[]—Text prefixes that trigger suggestions.
    splitstring' 'Separator appended after inserting a reference.
    loadingboolean—Show a loading state.
    notFoundContentReactNode—Content when no options match.

    Types and interaction

    Import the props and data types when creating reusable configuration.

    import type { MentionOption, MentionsProps } from '@ifhover/leaf-ui';

    Provide accessible labels for icon-only actions. Interactive controls support keyboard navigation and respect ConfigProvider themes and reduced motion.