Component Blueprints

Chat

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

  • 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?
  • Have you tried turning it off and on again?
    Jason Dewar • 5:02 PM
  • Chat ended by Andy Martinez • 5:30 PM

About Chat#

A chat consists of an unordered list of possible chat items, wrapped in a section which has the accessible role of log.

Accessibility#

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

Base#

<section role="log" class="slds-chat">
  <ul class="slds-chat-list">
    <li class="slds-chat-listitem"></li>
  </ul>
</section>

Structuring a chat#

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 itemModifierWhen to apply
Inbound message.slds-chat-listitem slds-chat-listitem_inboundApply to all list items that contain inbound messages
Outbound message.slds-chat-listitem slds-chat-listitem_outboundApply to all list items that contain outbound messages
Chat event.slds-chat-listitem slds-chat-listitem_eventApply to all list items that contain events
Chat bookend.slds-chat-listitem slds-chat-listitem_bookendApply to all list items that contain chat log bookends

The modifiers are used to apply any specific styling to the type of chat item it represents, including spacing, position and layout.

  • Chat started by Andy Martinez • 4:58 PM

  • 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?
  • I'm not trying to program any language
    Andy Martinez • 5:09 PM
  • Sorry to hear that. Let me see what I can do about this.
    Jason Dewar • 5:15 PM

Starting and ending a chat#

When each chat session is started or stopped, it is represented with a bookend. The bookend displays when the chat was stopped or started and by who.

Chat started bookend#

Chat started by Taylor Watson-Rice • 4:59 PM

<div class="slds-chat-bookend">
  <span class="slds-icon_container slds-icon-utility-chat slds-chat-icon">
    <svg class="slds-icon slds-icon_x-small slds-icon-text-default" aria-hidden="true">
      <use xlink:href="/assets/icons/utility-sprite/svg/symbols.svg#chat"></use>

Chat stopped bookend#

Chat ended by Taylor Watson-Rice • 4:59 PM

<div class="slds-chat-bookend slds-chat-bookend_stop">
  <span class="slds-icon_container slds-icon-utility-end_chat slds-chat-icon">
    <svg class="slds-icon slds-icon_x-small slds-icon-text-default" aria-hidden="true">
      <use xlink:href="/assets/icons/utility-sprite/svg/symbols.svg#end_chat"></use>

Chat messages#

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:

Inbound messages#

Use of aria-label

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.

  • Hi, my CloudWidget only speaks French
    Taylor Watson-Rice • 4:59 PM
<section role="log" class="slds-chat">
  <ul class="slds-chat-list">
    <li class="slds-chat-listitem slds-chat-listitem_inbound">
      <div class="slds-chat-message">

Consecutive inbound messages#

Consecutive messages only display name and time meta data once

  • Hi, my CloudWidget only speaks French
  • I'm having trouble changing that.
    Taylor Watson-Rice • 4:59 PM
<section role="log" class="slds-chat">
  <ul class="slds-chat-list">
    <li class="slds-chat-listitem slds-chat-listitem_inbound">
      <div class="slds-chat-message">

Inbound with avatar#

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.

  • Hi, my CloudWidget only speaks French
  • I'm having trouble changing that.
    Taylor Watson-Rice • 4:59 PM
<section role="log" class="slds-chat">
  <ul class="slds-chat-list">
    <li class="slds-chat-listitem slds-chat-listitem_inbound">
      <div class="slds-chat-message">

Receiving a file attachment#

During a chat an agent can request the customer upload a file attachment to be sent to the agent.

<section role="log" class="slds-chat">
  <ul class="slds-chat-list">
    <li class="slds-chat-listitem slds-chat-listitem_inbound">
      <div class="slds-chat-message">

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.

  • Preview:Description of the image
    Taylor Watson-Rice • 4:59 PM
<section role="log" class="slds-chat">
  <ul class="slds-chat-list">
    <li class="slds-chat-listitem slds-chat-listitem_inbound">
      <div class="slds-chat-message">

Non-image file formats are also supported by using the File component.

  • Preview:Description of the image
    pdf
    File.pdf
    Taylor Watson-Rice • 4:59 PM
<section role="log" class="slds-chat">
  <ul class="slds-chat-list">
    <li class="slds-chat-listitem slds-chat-listitem_inbound">
      <div class="slds-chat-message">

Both file and image transfers support messages with and without titles; however, titles are generally not recommended when transferring images.

  • Preview:Description of the image
  • Preview:Description of the image
    image
    Image.jpg
    Taylor Watson-Rice • 4:59 PM
<section role="log" class="slds-chat">
  <ul class="slds-chat-list">
    <li class="slds-chat-listitem slds-chat-listitem_inbound">
      <div class="slds-chat-message">

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.

  • Preview:Description of the image
    image
    Image.jpg
    Taylor Watson-Rice • 4:59 PM
<section role="log" class="slds-chat">
  <ul class="slds-chat-list">
    <li class="slds-chat-listitem slds-chat-listitem_outbound">
      <div class="slds-chat-message">

Customer is typing#

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"

  • Customer is typing
<section role="log" class="slds-chat">
  <ul class="slds-chat-list">
    <li class="slds-chat-listitem slds-chat-listitem_inbound">
      <div class="slds-chat-message">

Sneak peek#

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.

  • Customer is typing
<section role="log" class="slds-chat">
  <ul class="slds-chat-list">
    <li class="slds-chat-listitem slds-chat-listitem_inbound">
      <div class="slds-chat-message">

Outbound messages#

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.

Outbound message by current agent#

  • 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
    Amber Cann • 4:59 PM
<section role="log" class="slds-chat">
  <ul class="slds-chat-list">
    <li class="slds-chat-listitem slds-chat-listitem_outbound">
      <div class="slds-chat-message">

Outbound message by another agent#

  • So sorry to hear that. Let me transfer you to a more technical support member. Thank you for your patience. Have you tried visiting our help site?
    Jason Dewar • 4:59 PM
<section role="log" class="slds-chat">
  <ul class="slds-chat-list">
    <li class="slds-chat-listitem slds-chat-listitem_outbound">
      <div class="slds-chat-message">

Consecutive outbound messages#

For consecutive outbound messages the same rules apply to both types, as consecutive inbound messages.

  • Hi Andy, thank you for contacting Widget Support. Can you please tell me what language you are trying to program on your CloudWidget?
  • It might be the cause of the problem
    Taylor Watson-Rice • 4:59 PM
<section role="log" class="slds-chat">
  <ul class="slds-chat-list">
    <li class="slds-chat-listitem slds-chat-listitem_outbound">
      <div class="slds-chat-message">

Delivery Status Messages#

Unsupported Message Type (Inbound)#

If a customer tries sending a message that is not supported, it will appear as an unsupported message type.

  • WarningMessage type is not supported
    Taylor Watson-Rice • 4:59 PM
<section role="log" class="slds-chat">
  <ul class="slds-chat-list">
    <li class="slds-chat-listitem slds-chat-listitem_inbound">
      <div class="slds-chat-message">

Message Delivery Failure (Outbound)#

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
    Amber Cann • 4:59 PM
<section role="log" class="slds-chat">
  <ul class="slds-chat-list">
    <li class="slds-chat-listitem slds-chat-listitem_outbound">
      <div class="slds-chat-message">

Displaying events during a chat session#

During a chat session a number of events can occur and these are displayed to the agent, with descriptions and sometimes messages.

Basic chat event#

The basic type of events that can occur include:

  • Rasing a flag
  • Lowering a flag
  • A whisper
  • File request
  • File sent
  • File request cancelled
  • Transfer request
  • Transfer accepted
  • Transfer cancelled
  • Transfer declined
  • Jason Dewar raised a flag • 5:09 PM

  • Jason Dewar lowered the flag • 5:09 PM

  • Whisper from super SuperAlly • 5:09 PM

  • Jason Dewar sent a file request to Andy Martinez • 5:09 PM

  • Andy Martinez sent a file • 5:09 PM

  • Jason Dewar cancelled the file request • 5:09 PM

  • Jason Dewar sent a transfer request to Technical Support Team • 5:09 PM

  • Technical Support Team accepted the transfer request • 5:09 PM

  • Jason Dewar cancelled the transfer request • 5:09 PM

  • Technical Support Team declined the transfer request • 5:09 PM

<section role="log" class="slds-chat">
  <ul class="slds-chat-list">
    <li class="slds-chat-listitem slds-chat-listitem_event">
      <div class="slds-chat-event">

Chat event with an agent message#

Sometimes an agent might add a message to an event for another agent to read.

  • Jason Dewar sent a transfer request to Amber Cann • 5:19 PM

    Andy needs help changing the language on his CloudWidget
<section role="log" class="slds-chat">
  <ul class="slds-chat-list">
    <li class="slds-chat-listitem slds-chat-listitem_event">
      <div class="slds-chat-event">

Chat event - error#

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.

<section role="log" class="slds-chat">
  <ul class="slds-chat-list">
    <li class="slds-chat-listitem slds-chat-listitem_event">
      <div class="slds-chat-event slds-has-error" role="alert">

Putting it all together#

  • Chat started by Andy Martinez • 4:58 PM

  • 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?
  • Have you tried turning it off and on again?
    Jason Dewar • 5:02 PM
  • yes, of course
    Andy Martinez • 5:09 PM
  • Sorry to hear that. Let me transfer you to a more technical support member. Thank you for your patience!
    Jason Dewar • 5:15 PM
  • 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

  • Hi Andy, my name is Amber and I can help you solve your issue.
    Amber Cann • 5:23 PM
  • Nevermind, I speak french.
    Andy Martinez • 5:29 PM
  • Chat ended by Andy Martinez • 5:30 PM

<section role="log" class="slds-chat">
  <ul class="slds-chat-list">
    <li class="slds-chat-listitem slds-chat-listitem_bookend">
      <div class="slds-chat-bookend">

Past Chats#

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.
  • Andy Martinez • 5:29 PM
    Nevermind, I speak french.
  • Chat ended by Andy Martinez • 5:30 PM

<section role="log" class="slds-chat slds-chat_past">
  <ul class="slds-chat-list">
    <li class="slds-chat-listitem slds-chat-listitem_bookend">
      <div class="slds-chat-bookend">

Overview of CSS Classes#

Selector.slds-chat
Summary

Root container of a chat session

Supportdev-ready
Restrictsection[role="log"]
VariantTrue
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
ModifierTrue
Selector.slds-chat-listitem_inbound
Summary

Modifier used to style inbound message list items

Restrict.slds-chat-listitem
ModifierTrue
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

Restrict.slds-chat-message__body div
Selector.slds-chat-icon
Summary

Used to style icons with a chat log

Restrict.slds-chat-message__text .slds-icon_container, .slds-chat-event__body .slds-icon_container, .slds-chat-bookend .slds-icon_container, .slds-chat-message__action .slds-icon_container
Selector.slds-chat-message__text_inbound
Summary

Used for any specific inbound text styling

Restrict.slds-chat-message__text
Selector.slds-chat-message__text_outbound
Summary

Used for any specific outbound text styling

Restrict.slds-chat-message__text
Selector.slds-chat-message__text_outbound-agent
Summary

Used for any specific outbound (from another agent) text styling

Restrict.slds-chat-message__text
Selector.slds-chat-message__text_unsupported-type
Summary

Used for an inbound message that is not a supported message type

Restrict.slds-chat-message__text
ModifierTrue
Selector.slds-chat-message__text_delivery-failure
Summary

Used for an inbound message that fails to deliver

Restrict.slds-chat-message__text
ModifierTrue
Selector.slds-chat-message__text_delivery-failure-reason
Summary

Element that contains feedback for why inbound message failed

Restrict.slds-chat-message__text_delivery-failure [role="alert"]
Selector.slds-chat-message__text_sneak-peek
Summary

Used when sneak peek is enabled for customer messages

Restrict.slds-chat-message__text
ModifierTrue
Selector.slds-chat-message__file
Summary

true

Restrict.slds-chat-message__body div
Selector.slds-chat-message__file_inbound
Summary

Used for any specific inbound file styling

Restrict.slds-chat-message__file
Selector.slds-chat-message__meta
Summary

Used to style chat message meta data

Restrict.slds-chat-message div
Selector.slds-chat-message__action
Summary

Used to style chat message resend action

Restrict.slds-chat-message .slds-button
Selector.slds-chat-icon
Summary

Used to style icons with a chat log

Restrict.slds-chat-message__text .slds-icon_container, .slds-chat-event__body .slds-icon_container, .slds-chat-bookend .slds-icon_container, .slds-chat-message__action .slds-icon_container
Selector.slds-chat-event
Summary

During any chat, certain events can occur which need to be displayed to the user

Restrict.slds-chat-listitem div
Selector.slds-chat-event__ruleDeprecated
Summary

Used to style the horizontal rules on an event

Restrict.slds-chat-event div
Selector.slds-chat-event__body
Summary

Used for styling the event body text

Restrict.slds-chat-event div
Selector.slds-chat-icon
Summary

Used to style icons with a chat log

Restrict.slds-chat-message__text .slds-icon_container, .slds-chat-event__body .slds-icon_container, .slds-chat-bookend .slds-icon_container, .slds-chat-message__action .slds-icon_container
Selector.slds-chat-event__agent-message
Summary

Used to style any messages from an agent in the event

Restrict.slds-chat-event div
Selector.slds-has-error
Summary

Modifier to indicate the event was an error

Restrict.slds-chat-event[role="alert"]
ModifierTrue
Selector.slds-chat-bookend
Summary

Used to style a chat bookend

Restrict.slds-chat-listitem div
Selector.slds-chat-icon
Summary

Used to style icons with a chat log

Restrict.slds-chat-message__text .slds-icon_container, .slds-chat-event__body .slds-icon_container, .slds-chat-bookend .slds-icon_container, .slds-chat-message__action .slds-icon_container
Selector.slds-chat-bookend_stop
Summary

Modifier for bookends which stop a chat session

Restrict.slds-chat-bookend
ModifierTrue
Selector.slds-chat_past
Summary

Apply when displaying chat logs that appeared in the past

Supportdev-ready
Restrict.slds-chat
VariantTrue

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.").