Skip to content
Editor EditorMentionMenu

EditorMentionMenu

An @ menu that inserts a mention from a list of items.

On this page

Examples

Mentions

The mention is a span with data-type, data-id and data-label in the HTML.

Ada LovelaceMathematician
Alan TuringComputer scientist
Grace HopperRear admiral
Linus TorvaldsKernel maintainer

Type @ then a name. The mention is stored with its id.

(empty)

Razor
<div class="flex w-full max-w-2xl flex-col gap-3">
    <KlyFormField Label="Mentions" Help="Type @@ then a name. The mention is stored with its id.">
        <KlyEditor @bind-Value="_html" Placeholder="Mention a teammate with @@" data-testid="editor-mention">
            <KlyEditorMentionMenu Items="People" />
        </KlyEditor>
    </KlyFormField>
    <p class="break-all font-mono text-xs text-(--klyroo-text-muted)" data-testid="mention-html">@(string.IsNullOrEmpty(_html) ? "(empty)" : _html)</p>
</div>

@code {
    private string? _html = "";

    private static readonly EditorMentionItem[] People =
    [
        new("ada", "Ada Lovelace") { Description = "Mathematician" },
        new("alan", "Alan Turing") { Description = "Computer scientist" },
        new("grace", "Grace Hopper") { Description = "Rear admiral" },
        new("linus", "Linus Torvalds") { Description = "Kernel maintainer" },
    ];
}

API

KlyEditorMentionMenu

The mention menu: opens when "@" is typed and inserts a mention, a span with data-type="mention" , data-id and data-label . Items are supplied from .NET and filtered in the browser.

Parameters

Name Type Default Description
Char string Character that opens the menu.
Class string Classes added to the root element, merged last so they win over the theme.
Items (required) IReadOnlyList<EditorMentionItem> Who or what can be mentioned.
Label string Accessible name of the list.
Limit int 42 Most options shown at a time.
Size KlySize KlySize.Md Size of the menu, from Xs to Xl . Values: Xs, Sm, Md, Lg, Xl.
Ui EditorMenuUi Per-instance class overrides of the slots of the menu, see EditorMenuUi .

Ui slots

Ui takes a EditorMenuUi with one class string per slot, merged after the theme.

Slot Styles
Root Classes merged into the root slot of KlyEditorSuggestionMenu , KlyEditorMentionMenu and KlyEditorEmojiMenu , after the theme and the app configuration.
Content Classes merged into the content slot of KlyEditorSuggestionMenu , KlyEditorMentionMenu and KlyEditorEmojiMenu , after the theme and the app configuration.
Listbox Classes merged into the listbox slot of KlyEditorSuggestionMenu , KlyEditorMentionMenu and KlyEditorEmojiMenu , after the theme and the app configuration.
Item Classes merged into the item slot of KlyEditorSuggestionMenu , KlyEditorMentionMenu and KlyEditorEmojiMenu , after the theme and the app configuration.
Icon Classes merged into the icon slot of KlyEditorSuggestionMenu , KlyEditorMentionMenu and KlyEditorEmojiMenu , after the theme and the app configuration.
Body Classes merged into the body slot of KlyEditorSuggestionMenu , KlyEditorMentionMenu and KlyEditorEmojiMenu , after the theme and the app configuration.
ItemLabel Classes merged into the itemLabel slot of KlyEditorSuggestionMenu , KlyEditorMentionMenu and KlyEditorEmojiMenu , after the theme and the app configuration.
ItemDescription Classes merged into the itemDescription slot of KlyEditorSuggestionMenu , KlyEditorMentionMenu and KlyEditorEmojiMenu , after the theme and the app configuration.
Empty Classes merged into the empty slot of KlyEditorSuggestionMenu , KlyEditorMentionMenu and KlyEditorEmojiMenu , after the theme and the app configuration.

EditorMentionItem

An entry of KlyEditorMentionMenu : someone or something that can be mentioned.

Parameters

Name Type Description
Description string Text shown under the label.
Disabled bool Disables the entry.
Id string Stored in the mention as data-id .
Label string Shown in the menu and in the text after the @.