Message List Styling
Style Variants
The following style variants are supported by Message List:
| Variant | Description | Supported by |
|---|---|---|
| Shows the messages as chat bubbles | Aura, Lumo |
| Hides the avatars and names of all messages, for a conversation between two participants. Takes effect only together with | 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 |
|---|---|---|
| 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 |
| 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.
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 |
|---|---|
| Aura, Lumo |
| Aura, Lumo |
| Aura, Lumo |
| Aura, Lumo |
| Aura |
| Aura, Lumo |
| Aura, Lumo |
| Aura, Lumo |
| Aura, Lumo |
| Aura |
| Aura, Lumo |
| Aura, Lumo |
| Aura, Lumo |
| Aura, Lumo |
| Aura, Lumo |
| Aura, Lumo |
| Aura, Lumo |
| Aura, Lumo |
| Aura, Lumo |
| Aura, Lumo |
| Aura, Lumo |
| Aura, Lumo |
| Aura, Lumo |
| Aura, Lumo |
| Aura, Lumo |
| Aura, Lumo |
| Aura, Lumo |
| Aura, Lumo |
| Aura, Lumo |
| 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.
|
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)