Message List
API: TypeScript / Java
Source: TypeScript / Java
Message List allows you to show a list of messages, for example, a chat log.
- Usage
- Styling
Message List allows you to show a list of messages, for example, a chat log. You can configure the text content, information about the sender, and the time of sending for each message.
Open in a
new tab
new tab
<vaadin-message-list
.items="${[
{
text: 'Linsey, could you check if the details with the order are okay?',
time: this.yesterday,
userName: 'Matt Mambo',
userColorIndex: 1,
},
{
text: 'All good. Ship it.',
time: this.fiftyMinutesAgo,
userName: 'Linsey Listy',
userColorIndex: 2,
userImg: this.person ? this.person.pictureUrl : undefined,
},
]}"
></vaadin-message-list>
The messages in the list can be populated with the items
property. The items
property is of type Array
, with JSON objects in it. Each JSON object is a single message.
Styling
You can style individual messages by adding a theme property to some items and providing CSS for that theme. The following example shows how to highlight the current user’s own messages:
Open in a
new tab
new tab
<vaadin-message-list
.items="${[
{
text: 'Linsey, could you check if the details with the order are okay?',
time: this.yesterday,
userName: 'Matt Mambo',
userColorIndex: 1,
},
{
text: 'All good. Ship it.',
time: this.fiftyMinutesAgo,
userName: 'Linsey Listy',
userColorIndex: 2,
userImg: this.person ? this.person.pictureUrl : undefined,
/* Add custom class name */
className: 'current-user',
},
]}"
></vaadin-message-list>
Note
|
Use Theme Names, Not Class Names pre-V24.3
In versions prior to 24.3, theme names must be used instead of class names (theme property / addThemeNames Java method). The CSS syntax for targeting a theme name is [theme~="custom-theme"] .
|
Related Components
Component | Usage recommendations |
---|---|
Allow users to author and send messages. |
EE10DB8E-479C-41D0-9A77-BFA41C340BFB