The Chat component is used to display real-time and past chat logs between service agents and customers. It comes with a number of sub components that can be used to display the different types of chat items.
Chat started by Andy Martinez • 4:58 PM
AM
Hi, my CloudWidget only speaks French
Andy Martinez • 4:59 PM
Hi Andy, thank you for contacting Widget Support. Can you please tell me what language you are trying to program on your CloudWidget?
The log role has an implicit aria-live property value of polite, meaning that it comes for free. It also has an implicit aria-relevant property value of additions text. Together this means any additional text, or chat items added to the list will automatically be politely announced by a screen reader
To correctly structure and communicate a chat, you should first follow the basic structure (see above) that forms any chat log and can contain any type of chat item.
Each slds-chat-listitem comes with 4 modifier classes, each one needing to be applied based on the type of chat item you are display in the list item:
Chat messages are comprised of the message text, and message meta data including the persons name and time at which the message was sent. Chat messages come in 3 forms:
Each message meta data wrapper has aria-label added, which we can use to form more human sounding messages as they arrive, "Hi, my CloudWidget only speaks French said Taylor Watson-Rice at 4:59 PM". A screen reader, when aria-label is applied to an element, will only announce the contents of the label, not the text content held in it.
Inbound messages can optionally display the customers avatar. When displaying an avatar in inbound messages, be sure to apply the slds-chat-message_faux-avatar modifier to any consecutive slds-chat-message containers, to ensure correct alignment where the avatar is missing.
Aria Hidden Avatars
Because every inbound message already includes the user's name, the user's avatar is redundant and therefore should be treated as decorative. For this reason, we hide the avatar using aria-hidden="true" on the <span>with class="slds-avatar" to avoid redundancy for screen reader users.
It is also possible to display an image preview when sending a supported file format, such as a JPEG. This is accomplished by using the File component within Chat.
Contrast
When using actions without a title, it's important to use the slds-file__title_scrim class in conjunction with slds-file__title to ensure proper contrast. Without this, it can be difficult for users to see the action icons when the image being sent is predominantly light in color.
When sending or receiving a portrait-orientation image, use the slds-file__figure_portrait in conjunction with the slds-file__figure class. This will properly display the entire image within the chat message.
Whilst chatting with customers, agents can see when a customer is typing a response by using the Dynamic Icon, Typing.
Assistive text
It's important to set descriptive assistive text to the typing icon, as this is the only means a screen reader user will know a customer is currently typing. The assistive text, because it is text content, will be announced as the icon is added to the DOM. As an example, we use "Customer is typing"
We can take that experience one step further when the sneak peek feature is enabled. This allows agents to see what customers are typing in real time, as they type it.
aria-hidden
When the sneak peek feature is active, we take care to try and reduce the verbosity a screen reader user will encounter. As they will hear the final message once it is typed, we have found it is preferred to use aria-hidden="true" on the text they are currently typing, to reduce noise.
Outbound messages come in 2 forms. Ones that are written by the agent in the current chat session, and ones which have been written by other agents who have dealt with the customer during the same chat session.
Hi Taylor, thank you for contacting Widget Support. Can you please tell me what language you are trying to program on your CloudWidget? http://www/cloud.widget
If the agent attempts to send a message that can't be delivered, a message delivery failure indication appears beneath the original message text, along with an option to resend.
Role alert
Message delivery failures have the addition role="alert" to their container. A chat log has an aria-live="polite" value, but we would like to inform agents of errors immediately. The role="alert" attribute comes with an implicit aria-live value of assertive which will achieve this.
It might be the cause of the problem
Message was not delivered because Andy stopped receiving messages.
In the event of an error occurring during the chat, an error event can be displayed to the agent. This is done by adding the .slds-has-error modifier class.
Role alert
Event errors have the addition role="alert" to their container. A chat log has a aria-live="polite" value, but we would like to inform agents of errors immediately. The role="alert" attribute comes with an implicit aria-live value of assertive which will achieve this.
warning
The file sent by Andy Martinez is too large • 5:06 PM
An agent has the ability to view past chats with particular customers. In this instance the exact same components and markup for all types of chat items can be used, with just 4 differences:
A single modifier class of .slds-chat_past is added to the .slds-chat container
Each chat message .slds-chat-listitem container looses it's .slds-chat-listitem_inbound or .slds-chat-listitem_outbound modifier class
Each chat message .slds-chat-message__text looses it's .slds-chat-message__text_inbound or .slds-chat-message__text_outbound modifier class
.slds-chat-message__meta moves to before .slds-chat-message__text in DOM order
Chat started by Andy Martinez • 4:58 PM
Andy Martinez • 4:59 PM
Hi, my CloudWidget only speaks French
Jason Dewar • 5:02 PM
Hi Andy, thank you for contacting Widget Support. Can you please tell me what language you are trying to program on your CloudWidget?
Jason Dewar • 5:03 PM
Have you tried turning it off and on again?
Andy Martinez • 5:09 PM
yes, of course
Jason Dewar • 5:15 PM
Sorry to hear that. Let me transfer you to a more technical support member. Thank you for your patience!
Jason Dewar sent a transfer request to Technical Support Team • 5:19 PM
Andy needs help changing the language on his CloudWidget
Technical Support Team accepted the transfer request • 5:20 PM
Amber Cann accepted this chat • 5:22 PM
Amber Cann • 5:23 PM
Hi Andy, my name is Amber and I can help you solve your issue.
Whether the class name is dev-ready (meaning it's fully vetted and tested and safe to use) or prototype (which means it's not fully vetted yet).
Restrict
The selector that the class name is allowed to be used on.
Variant
The base level pattern for a component. A variant can be extended to create another variant of that component, for example, a stateful button is a derivative of the base button.
Modifier
A single class that can be added to an HTML element of a component to modify its output. Typically these will be colors, sizing and positioning.
Selector
.slds-chat
Summary
Root container of a chat session
Support
dev-ready
Restrict
section[role="log"]
Variant
True
Selector
.slds-chat-list
Summary
Handles the display of chat items within a list
Restrict
.slds-chat ul
Selector
.slds-chat-listitem
Summary
Handles spacing and direction of items in the list
Restrict
.slds-chat-list li
Selector
.slds-chat-listitem_outbound
Summary
Modifier used to style outbound message list items
Restrict
.slds-chat-listitem
Modifier
True
Selector
.slds-chat-listitem_inbound
Summary
Modifier used to style inbound message list items
Restrict
.slds-chat-listitem
Modifier
True
Selector
.slds-chat-listitem_bookend
Summary
Modifier used for spacing bookend items
Restrict
.slds-chat-listitem
Selector
.slds-chat-listitem_event
Summary
Modifier used for spacing event items
Restrict
.slds-chat-listitem
Selector
.slds-chat-message
Summary
styles the outter part of a chat message
Restrict
.slds-chat-listitem div
Selector
.slds-chat-message_faux-avatar
Summary
Used for when customer avatars are used in consequtive inbound messages to align the message body with the previous message
Restrict
.slds-chat-message
Selector
.slds-chat-avatar
Summary
Used to style avatars in chat logs
Restrict
.slds-chat-message .slds-avatar
Selector
.slds-chat-avatar__intialsDeprecated
Summary
Used to style the avatar intials for chat
Restrict
.slds-chat-avatar .slds-avatar__initials
Selector
.slds-chat-message__body
Summary
Used to contain and align chat messages with their avatars
Restrict
.slds-chat-message div
Selector
.slds-chat-message__image_loading
Summary
true
Restrict
.slds-chat-message__body
Selector
.slds-chat-message__text
Summary
Used to style the chat text from agent or customer
Apply when displaying chat logs that appeared in the past
Support
dev-ready
Restrict
.slds-chat
Variant
True
Chat Release Notes
2.11.0
Fixed
Fixed an issue where some message text containers would have a width equal to the message meta even though the container contained less text and should have had a smaller width.
2.10.0
Changed
Horizontal rules have been removed from event messages for an improved chat experience, .slds-chat-event__rule is no longer used and marked as deprecated
Bookends now span full width which allows the bookend borders to be visually flush with their container .slds-chat-list
Horizontal padding added to .slds-chat-bookend to compensate for the negative margins used to make the bookend span full width
2.8.0
Changed
Added aria-hidden="true" to the Avatar for inbound chat messages to avoid duplication of the user's name for screen reader users
2.7.0
Added
File component (image and file content types) is now natively supported within an inbound and outbound message.
Fixed
Outbound messages that contain a string of text shorter than the max-width no longer has unnecessary white space.
Removed unnecessary whitespace when sending messages with a small amount of text (.e.g, "Hi there.").