Class TwMessage
- Namespace
- TwBlazor.Components
- Assembly
- TwBlazor.dll
Represents one message in a conversation: an avatar beside a column holding the author, the time, the content and an optional footer.
public class TwMessage : TwBlazorComponentBase, IComponent, IHandleEvent, IHandleAfterRender, ITwComponent
- Inheritance
-
TwMessage
- Implements
- Inherited Members
Remarks
Put the message's text in a TwBubble as its content. The bubble picks up the message's Align, so the current user's messages can sit at the end edge and everyone else's at the start.
Accessibility: each message is an article named by its author and time, so screen reader users can move
from message to message. The avatar is decoration, because the author's name is already written beside it. A
Continued message hides its header from view but keeps it for screen readers, so every message
still says who sent it. Put the messages in a container with role="log" so new ones are announced.
Constructors
TwMessage()
public TwMessage()
Properties
Align
Gets or sets which side of the conversation the message sits on.
[Parameter]
public MessageAlign Align { get; set; }
Property Value
Author
Gets or sets the name of the person or assistant who sent the message. It is shown above the content and supplies the avatar's initials.
[Parameter]
public string? Author { get; set; }
Property Value
AvatarColor
Gets or sets the color behind the avatar's initials or icon.
[Parameter]
public Color? AvatarColor { get; set; }
Property Value
AvatarContent
Gets or sets custom content shown in place of the built-in TwAvatar.
[Parameter]
public RenderFragment? AvatarContent { get; set; }
Property Value
AvatarIcon
Gets or sets an icon the avatar shows in place of initials worked out from the Author, for example Robot for an assistant.
[Parameter]
public Icon? AvatarIcon { get; set; }
Property Value
- Icon?
Remarks
A picture from AvatarSrc or explicit AvatarInitials still take precedence.
AvatarInitials
Gets or sets the avatar's initials.
[Parameter]
public string? AvatarInitials { get; set; }
Property Value
Remarks
If not set, they are worked out from Author, unless AvatarIcon is set.
AvatarSrc
Gets or sets the URL of the avatar's picture.
[Parameter]
public string? AvatarSrc { get; set; }
Property Value
ChildContent
Gets or sets the content of the message, usually a TwBubble.
[Parameter]
public RenderFragment? ChildContent { get; set; }
Property Value
Continued
Gets or sets whether the message continues one from the same author just above it. Its avatar and header are hidden from view, and the content stays in line with the message above.
[Parameter]
public bool Continued { get; set; }
Property Value
Footer
Gets or sets content shown under the message, such as actions or a delivery state.
[Parameter]
public RenderFragment? Footer { get; set; }
Property Value
ShowAvatar
Gets or sets whether the avatar column is shown.
[Parameter]
public bool ShowAvatar { get; set; }
Property Value
Timestamp
Gets or sets when the message was sent. It is shown beside the author.
[Parameter]
public DateTime? Timestamp { get; set; }
Property Value
TimestampFormat
Gets or sets the .NET format string the Timestamp is shown with.
[Parameter]
public string? TimestampFormat { get; set; }
Property Value
Remarks
If not set, the current culture's short time is used, for example 14:05 in en-GB.
Methods
BuildRenderTree(RenderTreeBuilder)
Renders the component to the supplied RenderTreeBuilder.
protected override void BuildRenderTree(RenderTreeBuilder __builder)
Parameters
__builderRenderTreeBuilder