Skip to content
IzzyBlazor

Enter all results ↑ ↓ move Esc close

Comment

Since 0.1.0-alpha.24
Shows a comment in a discussion, with who wrote it, when, and replies nested under it.

Comment: one comment in a discussion, such as feedback under an article or a review on a pull request. Replies nest inside it. For messages exchanged as they happen, see Chat.

Author, time and actions

Set Author, Time and Text. The avatar shows the author's initials, or a picture from Avatar. To add buttons such as Reply under the comment, set Actions.

Static

Preview

Priya Natarajan

Does the export keep the column order I set in the grid, or the order in the database?

Code

Usage.razor
@* A question under a help article, with votes and a reply: the row most comment sections have. *@
<Comment Author="Priya Natarajan" Time="_posted"
         Text="Does the export keep the column order I set in the grid, or the order in the database?">
    <Actions>
        <Button Variant="ButtonVariant.Ghost" Accent="Accent.Neutral" Size="ControlSize.Sm" StartIcon="Lucide.ArrowBigUp" aria-label="Upvote, 23">23</Button>
        <IconButton Icon="Lucide.ArrowBigDown" Label="Downvote" Variant="ButtonVariant.Ghost" Accent="Accent.Neutral" Size="ControlSize.Sm" />
        <Button Variant="ButtonVariant.Ghost" Accent="Accent.Neutral" Size="ControlSize.Sm" StartIcon="Lucide.Reply">Reply</Button>
    </Actions>
</Comment>

@code {
    private readonly DateTimeOffset _posted = new(2026, 11, 4, 14, 20, 0, TimeSpan.Zero);
}

Add this example to a page with the izzy CLI:

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

Replies

To answer a comment, put Comments in its Replies. Each level steps in by one avatar.

Static

Preview

Marcus Webb

Does the retry here back off, or will it hammer the payments API when it's down?

Lena Okafor

It backs off: 1, 2, then 4 seconds, and gives up after three tries.

Marcus Webb

Good. Could the delays go in the config, so ops can change them?

Lena Okafor

Done, under Payments:RetryDelays.

Show 3 more replies

Code

Replies.razor
@inject NavigationManager Navigation

@* A question on a pull request and the answers to it, two levels deep, with the rest of the
   replies a click away. *@
<Comment Author="Marcus Webb" Time="_now.AddHours(-5)" RelativeTime
         Text="Does the retry here back off, or will it hammer the payments API when it's down?">
    <Actions>
        <Button Variant="ButtonVariant.Ghost" Accent="Accent.Neutral" Size="ControlSize.Sm">Reply</Button>
    </Actions>
    <Replies>
        <Comment Author="Lena Okafor" Time="_now.AddHours(-4)" RelativeTime
                 Text="It backs off: 1, 2, then 4 seconds, and gives up after three tries.">
            <Actions>
                <Button Variant="ButtonVariant.Ghost" Accent="Accent.Neutral" Size="ControlSize.Sm">Reply</Button>
            </Actions>
            <Replies>
                <Comment Author="Marcus Webb" Time="_now.AddHours(-3)" RelativeTime
                         Text="Good. Could the delays go in the config, so ops can change them?" />
                <Comment Author="Lena Okafor" Time="_now.AddMinutes(-40)" RelativeTime
                         Text="Done, under Payments:RetryDelays." />
            </Replies>
        </Comment>
        @if (Thread == "all")
        {
            <Comment Author="Priya Shah" Time="_now.AddMinutes(-30)" RelativeTime
                     Text="Worth logging each retry at Warning, so we see it before it gives up." />
            <Comment Author="Lena Okafor" Time="_now.AddMinutes(-20)" RelativeTime
                     Text="Added, with the attempt number in the message." />
            <Comment Author="Marcus Webb" Time="_now.AddMinutes(-5)" RelativeTime Text="Approved." />
        }
        else
        {
            @* A link, so it works with JavaScript off: the page comes back with every reply. *@
            <Button Href="@Navigation.GetUriWithQueryParameter("thread", "all")" Variant="ButtonVariant.Link" Size="ControlSize.Sm">Show 3 more replies</Button>
        }
    </Replies>
</Comment>

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

    private readonly DateTimeOffset _now = DateTimeOffset.UtcNow;
}

To load the rest of a long thread, put a link button after the replies. As a link, it works with JavaScript off.

RelativeTime shows how long ago ("5 hours ago") with the full date on hover, worked out when the page renders. Comments older than a week show their date.

A list of comments

For a page's comments, put them in a Stack with a count above and a Divider between.

Static

Preview

3 comments

Tomás Rivera

Edited

Step 3 still shows the old Settings menu. It's under Account now.


Grace Liu

This fixed my export. The note about time zones was the missing piece.


Sam Patel

Could you add how to export only the selected rows?

Noor Haddad

Writer

Added under Selected rows, with a screenshot of the menu.

Code

List.razor
@* Feedback on a help article: a count, then each comment, newest first, with a line between.
   The writer's answer is marked as theirs, and an edited comment says so. *@
<Stack Gap="5" Grow>
    <Heading Level="2" Size="TextSize.Md">@_comments.Length comments</Heading>
    @foreach (var (comment, i) in _comments.Select((c, i) => (c, i)))
    {
        @if (i > 0)
        {
            <Divider />
        }
        <Comment Author="@comment.Author" Time="comment.Time" RelativeTime Text="@comment.Text"
                 Extra="@(comment.Edited ? _edited : null)" Replies="@(comment.Answer is { } answer ? WritersAnswer(answer) : null)" />
    }
</Stack>

@code {
    private readonly RenderFragment _edited = @<span>Edited</span>;

    private static RenderFragment WritersAnswer(Answer answer) =>
        @<Comment Author="Noor Haddad" Time="answer.Time" RelativeTime Text="@answer.Text">
            <Extra><Badge Size="BadgeSize.Sm">Writer</Badge></Extra>
        </Comment>;

    private sealed record Answer(DateTimeOffset Time, string Text);

    private sealed record Feedback(string Author, DateTimeOffset Time, string Text, bool Edited = false, Answer? Answer = null);

    private readonly Feedback[] _comments =
    [
        new("Tomás Rivera", DateTimeOffset.UtcNow.AddHours(-2), "Step 3 still shows the old Settings menu. It's under Account now.", Edited: true),
        new("Grace Liu", DateTimeOffset.UtcNow.AddDays(-1), "This fixed my export. The note about time zones was the missing piece."),
        new("Sam Patel", DateTimeOffset.UtcNow.AddDays(-3), "Could you add how to export only the selected rows?",
            Answer: new(DateTimeOffset.UtcNow.AddDays(-2), "Added under Selected rows, with a screenshot of the menu.")),
    ];
}

Extra adds to the author's line after the time, such as "Edited", a Badge or a Menu.

Adding a comment

For a box to write in, put a form in a Comment that has only the signed-in user's Initials or Avatar: it lines up with the comments above.

Static

Preview

Aisha Bello

The vendor sent the revised quote. It's attached to the task.

Daniel Kim

It's 8% over budget. I'll ask whether they can drop the install fee.

Code

ReplyForm.razor
@* A task's comments with a box to add yours: a Comment with your avatar and a form inside.
   Jordan Ellis is the signed-in user. *@
@using System.ComponentModel.DataAnnotations

<Stack Gap="6" Grow>
    @foreach (var comment in _comments)
    {
        <Comment Author="@comment.Author" Time="comment.Time" RelativeTime Text="@comment.Text" />
    }
    <Comment Initials="JE">
        <Form Model="Model" FormName="comment-reply-form" OnValidSubmit="Add">
            <TextArea @bind-Value="Model!.Text" Rows="2" AutoGrow HideLabel Placeholder="Add a comment" />
            <FormActions>
                <Button Submit Size="ControlSize.Sm">Comment</Button>
            </FormActions>
        </Form>
    </Comment>
</Stack>

@code {
    [SupplyParameterFromForm(FormName = "comment-reply-form")]
    private Draft? Model { get; set; }

    private readonly List<Posted> _comments =
    [
        new("Aisha Bello", DateTimeOffset.UtcNow.AddHours(-6), "The vendor sent the revised quote. It's attached to the task."),
        new("Daniel Kim", DateTimeOffset.UtcNow.AddHours(-1), "It's 8% over budget. I'll ask whether they can drop the install fee."),
    ];

    protected override void OnInitialized() => Model ??= new();

    // On a static page the post adds it to this render; an app saves it, then shows the task again.
    private void Add()
    {
        _comments.Add(new("Jordan Ellis", DateTimeOffset.UtcNow, Model!.Text!.Trim()));
        Model = new();
    }
}

For a conversation as it happens, Chat suits better.

Details

The content is Text (plain, its lines kept) or anything else as ChildContent, which is also where a reply form goes: a Comment with only an Avatar or Initials and a TextArea inside reads as "you, writing". Replies step in by one avatar's width at each level. RelativeTime shows "2 hours ago" in place of the date, computed when the page renders, with the full date on hover. Extra adds to the author's line after the time: a Badge, "Edited", or a Menu.

Mode support

What works in each mode, Comment
FeatureStaticInteractive
EverythingYesYes

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

Accessibility

  • The author's name is a heading (HeadingLevel, 3 by default), so screen readers can jump from comment to comment, as they do on GitHub.
  • Each comment is an article named by its author, its replies nested inside it, so a reply can be told from the comment it answers. Without an Author (a reply form) it's a plain div.
  • The time is a time element with the exact date and time in datetime.
  • The avatar is decoration: the author's name is next to it.

Parameters

Comment parameters
PropTypeDefault
AuthorWho wrote it.string?
AvatarThe address of the author's picture.string?
InitialsThe avatar's letters, in place of the author's initials.string?
TimeWhen it was written, shown after the author: the date and time, or how long ago with RelativeTime.DateTimeOffset?
RelativeTimeShows Time as how long ago ("5 minutes ago", "3 days ago"), with the full date on hover, as a RelativeTime that stays current as the page stays open.boolfalse
TimeTextTime as your app writes it, such as "Nov 14 · 12:10 PM", in place of the culture's short date and time.string?
ExtraMore on the author's line, after the time: a Badge such as "Author" or "Moderator", the word "Edited", or a Menu of what you can do with it.RenderFragment?
TextThe comment as plain text, its line breaks kept.string?
ChildContentThe comment as anything else: formatted text, an image, or a reply form.RenderFragment?
ActionsA row under the comment for things to do with it, such as Reply and Like buttons.RenderFragment?
RepliesReplies: more Comments, nested inside this one and stepped in, and a link to load more.RenderFragment?
HeadingLevelThe author's heading level, 2 to 6.int3

See also

  • Chat: builds an AI assistant's chat panel or a conversation between people.
  • Timeline: shows events on a rail, such as an order's history.
  • Avatar: shows a photo, initials or an icon for a person or thing.

Connection lost

Rejoining the server…