Add text and images to cards (original) (raw)

This page explains how to add and format text and images to cards.

To learn more about building cards, seeBuild cards for Google Chat apps.


Use the Card Builder to design and preview messaging and user interfaces for Chat apps:

Open the Card Builder


Prerequisites

A Google Chat app that's enabled for interactive features. To create an interactive Chat app, complete one of the following quickstarts based on the app architecture that you want to use:

Add images or icons

This section explains how to add visual elements to cards such as images, image components, and icons.

Add an image

Image widgetdisplays a PNG or JPG image hosted on an HTTPS URL. The displayed image's width fills the entire width of the displayed card, and its height adjusts to maintain the image's aspect ratio. The Image widget supportsonclick actionsthat occur when users click the image. Example of onclick actions include:

The Image widget has the following limitations:

The following is a card consisting of an Image widget. It displays the Google Chat developer documentation landing page image. When users click the image, the Google Chat developer documentation opens in a new tab.

Add an image component

The Image widget is an image with limited styling. AnimageCompent widgetlets you apply cropStyle and borderStyle to an image.

The following example shows two images in a grid where one of the images is cropped:

You can adjust the shape of an image component by applying acropStyle. There are several shapes to apply to an image:

The following example shows five images in a grid with a different cropStyleapplied to each image:

Add an icon

TheIcon widgetrepresents either abuilt-inicon orcustomicon. You add icons to cards to do any of the following:

The following is a card consisting of an Icon component with a built-in icon:

The following table lists the built-in icons that are available for card messages:

AIRPLANE BOOKMARK
BUS CAR
CLOCK CONFIRMATION_NUMBER_ICON
DESCRIPTION DOLLAR
EMAIL EVENT_SEAT
FLIGHT_ARRIVAL FLIGHT_DEPARTURE
HOTEL HOTEL_ROOM_TYPE
INVITE MAP_PIN
MEMBERSHIP MULTIPLE_PEOPLE
PERSON PHONE
RESTAURANT_ICON SHOPPING_CART
STAR STORE
TICKET TRAIN
VIDEO_CAMERA VIDEO_PLAY

Add text to a card

This section explains how to add and format text in a card.

Add a paragraph of formatted text

TheTextParagraph widgetdisplays a paragraph of text with optional HTML formatting. When setting the text content of these widgets, just include the corresponding HTML tags. For more information about which HTML tags are supported, seeFormat text that appears in cards.

For example, the following formatting is available for paragraph text:

Each TextParagraph widget renders as a new paragraph, and can be thought of as similar to an HTML <p> tag.

The following is a card consisting of two TextParagraph widgets used to display two paragraphs with simple HTML formatting:

Add a collapsible text paragraph

The collapsible text paragraphs let users reveal more information on demand. This widget is perfect for presenting lengthy content or additional details that can be explored when selected, creating a dynamic and interactive user experience.

Display text with decorative elements

TheDecoratedText widgetdisplays text with optional layout and capabilities. For example:

Use the DecoratedText widget when you need to present information in an easy-to-consume and interactive way. The widget is perfect for use cases such as contact cards, order status updates, and work ticket notifications.

The DecoratedText widget supports simple text HTML formatting. When setting the text content of these widgets, just include the corresponding HTML tags. For more information about which HTML tags are supported, seeCard text formatting.

The following is a card consisting of a DecoratedText widget used to display contact details, such as email address, online status, phone number, and website:

Troubleshoot

When a Google Chat app orcard returns an error, the Chat interface surfaces a message saying "Something went wrong." or "Unable to process your request." Sometimes the Chat UI doesn't display any error message, but the Chat app or card produces an unexpected result; for example, a card message might not appear.

Although an error message might not display in the Chat UI, descriptive error messages and log data are available to help you fix errors when error logging for Chat apps is turned on. For help viewing, debugging, and fixing errors, seeTroubleshoot and fix Google Chat errors.