Docs

Message List Styling

Styling API reference for the Message List component.

Style Variants

The following style variants are supported by Message List:

Variant Description Supported by

bubble

Shows the messages as chat bubbles

Aura, Lumo

one-to-one

Hides the avatars and names of all messages, for a conversation between two participants. Takes effect only together with bubble.

Aura, Lumo

The following style variants are supported by individual messages. They take effect only when the list uses the bubble variant:

Variant Description Supported by

self

Shows the message as sent by the current user: aligned to the end, tinted with the user color, and without the avatar and name

Aura, Lumo

full-width

Removes the bubble and the width restriction, for example for the responses of an AI assistant

Aura, Lumo

The message variants are applied to the items, not to the list: in Flow with addThemeVariants() on MessageListItem and the MessageListItemVariant constants, and in Lit and React with the theme property of an item.

Chat Bubbles

The bubble variant shows each message in a bubble that fits its content, with the avatar next to it. Apply the self variant to the messages of the current user. Their bubbles are aligned to the end of the list and tinted with the user color, which is the same color that the user color index gives the avatar. The variant also hides the avatar and name, but screen readers still announce the name.

Source code
MessageListBubble.java
message-list-bubble.tsx
message-list-bubble.ts

One-to-One Conversations

In a conversation between two participants, such as a chat with an AI assistant, the position of a message already tells who sent it. The one-to-one variant hides the avatars and names of all messages, while the self variant keeps the messages of the current user aligned to the end. As with the self variant, screen readers still announce the names.

The full-width variant removes the bubble and the width restriction from a message. Use it for the responses of an AI assistant, which are often long and formatted with Markdown.

Source code
MessageListOneToOne.java
message-list-one-to-one.tsx
message-list-one-to-one.ts

Styling Individual Messages

You can style individual messages by adding a class name to some items and providing CSS for that class name. The following example shows how to highlight the current user’s own messages:

Source code
MessageListClassName.java
message-list-class-name.css
message-list-class-name.css
message-list-class-name.tsx
message-list-class-name.css
message-list-class-name.css
message-list-class-name.ts
message-list-class-name.css
message-list-class-name.css

In a list with the bubble variant, use the self variant for the messages of the current user instead.

Style Properties

The following style properties can be used in CSS stylesheets to customize the appearance of this component.

To apply values to these properties globally in your application UI, place them in a CSS block using the html {…​} selector. See Component Style Properties for more information on style properties.

Property Supported by

--vaadin-message-attachment-background

Aura, Lumo

--vaadin-message-attachment-border-color

Aura, Lumo

--vaadin-message-attachment-border-radius

Aura, Lumo

--vaadin-message-attachment-border-width

Aura, Lumo

--vaadin-message-attachment-font-size

Aura

--vaadin-message-attachment-font-weight

Aura, Lumo

--vaadin-message-attachment-gap

Aura, Lumo

--vaadin-message-attachment-line-height

Aura, Lumo

--vaadin-message-attachment-padding

Aura, Lumo

--vaadin-message-attachment-text-color

Aura

--vaadin-message-attachments-alignment

Aura, Lumo

--vaadin-message-content-background

Aura, Lumo

--vaadin-message-content-border-radius

Aura, Lumo

--vaadin-message-content-padding

Aura, Lumo

--vaadin-message-font-size

Aura, Lumo

--vaadin-message-font-weight

Aura, Lumo

--vaadin-message-gap

Aura, Lumo

--vaadin-message-header-line-height

Aura, Lumo

--vaadin-message-line-height

Aura, Lumo

--vaadin-message-list-max-width

Aura, Lumo

--vaadin-message-list-padding

Aura, Lumo

--vaadin-message-name-color

Aura, Lumo

--vaadin-message-name-font-size

Aura, Lumo

--vaadin-message-name-font-weight

Aura, Lumo

--vaadin-message-padding

Aura, Lumo

--vaadin-message-text-color

Aura, Lumo

--vaadin-message-time-color

Aura, Lumo

--vaadin-message-time-font-size

Aura, Lumo

--vaadin-message-time-font-weight

Aura, Lumo

--vaadin-message-user-color

Aura, Lumo

CSS Selectors

The following CSS selectors can be used in stylesheets to target the various parts and states of the component. See the Styling documentation for more details on how to style components.

Important
Not for Shadow DOM
These selectors should be used in styles.css or another stylesheet loaded with the @StyleSheet annotation or the @import CSS rule. They do not work in the shadow DOM of Vaadin components, such as in stylesheets in the components sub-folder or loaded with the @CssImport annotation’s themeFor property.

List

Root element

vaadin-message-list

Internal list layout

vaadin-message-list::part(list)

Message

Root element

vaadin-message

Focused message

vaadin-message[focused]

Keyboard focused message

vaadin-message[focus-ring]

Text content layout

vaadin-message::part(content)

Header row

vaadin-message::part(header)

Name

vaadin-message::part(name)

Timestamp

vaadin-message::part(time)

Message text

vaadin-message::part(message)

Attachments

Attachments container

vaadin-message::part(attachments)

Attachment button

vaadin-message::part(attachment)

Image attachment button

vaadin-message::part(attachment attachment-image)

File attachment button

vaadin-message::part(attachment attachment-file)

Image thumbnail

vaadin-message::part(attachment-preview)

File icon

vaadin-message::part(attachment-icon)

File name

vaadin-message::part(attachment-name)

Avatars

Avatar

vaadin-message > vaadin-avatar

Avatar icon

vaadin-message > vaadin-avatar::part(icon)

Avatar abbreviation

vaadin-message > vaadin-avatar::part(abbr)

Typing Indicator Flow

Typing indicator

vaadin-message[typing-indicator]

Typing user avatars

vaadin-message[typing-indicator] > vaadin-avatar-group

Updated –