Skip to content
IzzyBlazor

Enter all results ↑ ↓ move Esc close

MentionText

Since 0.1.0-alpha.24
Shows text written in a Mentions field, with each @name marked or linked.

Text written in a Mentions<T> field, shown with each mention marked, or linked with Href. Its lines are kept.

Mentions in a comment

Set Text to the saved text: each mention is marked, and Href links it to a profile; here the link opens it under the comment. Its lines are kept.

Static

Preview

Aisha Bello

The revised quote is in. @daniel.kim can you check it against the budget? @mei.chen the install dates moved to the 14th.

Code

Usage.razor
@* A posted comment's text with its mentions linked; a link opens that person's profile under it. *@
@inject NavigationManager Navigation

<Stack Gap="4" Grow>
    <Comment Author="Aisha Bello" Time="_posted" RelativeTime>
        <MentionText Text="@_text" Href="ProfileOf" />
    </Comment>
    @if (Profile is not null && Team.TryGetValue(Profile, out var person))
    {
        <Card MaxWidth="20.Rem">
            <Row Gap="3" Align="Align.Center">
                <Avatar Name="@person.Name" Decorative />
                <Stack Gap="0">
                    <TextBlock Weight="FontWeight.Medium">@person.Name</TextBlock>
                    <TextBlock Size="TextSize.Sm" Color="Color.Muted">@person.Role</TextBlock>
                </Stack>
            </Row>
        </Card>
    }
</Stack>

@code {
    [SupplyParameterFromQuery(Name = "profile")] private string? Profile { get; set; }

    private readonly DateTimeOffset _posted = DateTimeOffset.UtcNow.AddHours(-3);

    private readonly string _text = """
        The revised quote is in. @daniel.kim can you check it against the budget?
        @mei.chen the install dates moved to the 14th.
        """;

    // An app links to its profile page, such as $"/people/{m.Text}".
    private string ProfileOf(Mention m) => Navigation.GetUriWithQueryParameter("profile", m.Text) + "#ex-mention-text-usage";
}

Add this example to a page with the izzy CLI:

bash
izzy add component MentionText --at <file>:<line>

Prefixes sets the triggers to find, as on the Mentions field that wrote the text. Mention.Parse finds the same names in C#, to notify the people mentioned.

Details

Mentions are found as Parse finds them.

Mode support

What works in each mode, MentionText
FeatureStaticInteractive
EverythingYesYes

Static: static server-side rendering, with no circuit and no WebAssembly. Interactive: Server, WebAssembly or Auto.

Accessibility

  • A mention without a link is text in a different color and weight, read as part of the sentence.
  • With Href, each mention is a link named by its text, such as "@ana".

Parameters

MentionText parameters
PropTypeDefault
TextThe text to show.string?Required
PrefixesThe characters that start a mention.IReadOnlyList<string>?@
HrefWhere a mention links to, such as the person's profile; null for no link.Func<Mention, string?>?

See also

  • Mentions: suggests people or tags as the user types @ or # in a text area, and writes the chosen name into the text.
  • Comment: shows a comment in a discussion, with who wrote it, when, and replies nested under it.

Connection lost

Rejoining the server…