[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-08-29 (世界標準時間)。"],[[["\u003cp\u003eThis page guides you on adding and formatting text and images within Google Chat cards to enhance their visual appeal and interactivity.\u003c/p\u003e\n"],["\u003cp\u003eYou can incorporate images, icons, and formatted text paragraphs using various widgets and HTML formatting options.\u003c/p\u003e\n"],["\u003cp\u003eLearn how to use \u003ccode\u003eImage\u003c/code\u003e, \u003ccode\u003eimageComponent\u003c/code\u003e, \u003ccode\u003eIcon\u003c/code\u003e, \u003ccode\u003eTextParagraph\u003c/code\u003e, and \u003ccode\u003eDecoratedText\u003c/code\u003e widgets to build engaging cards.\u003c/p\u003e\n"],["\u003cp\u003eLeverage built-in or custom icons, apply cropping and border styles to images, and add interactive elements like buttons or hyperlinks.\u003c/p\u003e\n"],["\u003cp\u003eRefer to the troubleshooting section for assistance if you encounter any errors while implementing these features.\u003c/p\u003e\n"]]],[],null,["# Add text and images to cards\n\nThis page explains how to add and format text and images to cards.\n\nTo learn more about building cards, see\n[Build cards for Google Chat apps](/workspace/chat/design-components-card-dialog).\n\n\n*** ** * ** ***\n\nUse the Card Builder to design and preview messaging and user interfaces for Chat apps:\n[Open the Card Builder](https://addons.gsuite.google.com/uikit/builder)\n\n*** ** * ** ***\n\n\u003cbr /\u003e\n\nPrerequisites\n-------------\n\n\nA Google Chat app that's configured to receive and respond to [interaction events](/workspace/chat/receive-respond-interactions). To create an\ninteractive Chat app, complete one of the following quickstarts based\non the [app architecture](/workspace/chat/structure) that you want to use:\n\n- [HTTP service](/workspace/chat/quickstart/gcf-app) with Google Cloud Functions\n- [Google Apps Script](/workspace/chat/quickstart/apps-script-app)\n- [Google Cloud Dialogflow CX](/workspace/chat/build-dialogflow-chat-app-natural-language)\n- [Google Cloud Pub/Sub](/workspace/chat/quickstart/pub-sub)\n\nAdd images or icons\n-------------------\n\nThis section explains how to add visual elements to cards such as images,\nimage components, and icons.\n\n### Add an image\n\n[`Image` widget](/workspace/chat/api/reference/rest/v1/cards#image)\ndisplays a PNG or JPG image hosted on an HTTPS URL.\nThe displayed image's width fills the entire width of the displayed card, and\nits height adjusts to maintain the image's aspect ratio. The `Image` widget\nsupports\n[`onclick` actions](/workspace/chat/api/reference/rest/v1/cards#OnClick_1)\nthat occur when users click the image. Example of `onclick` actions include:\n\n- Open a hyperlink with [`OpenLink`](/workspace/chat/api/reference/rest/v1/cards#OpenLink_1), such as a hyperlink to the Google Chat developer documentation, `https://developers.google.com/chat`.\n- Run an [action](/workspace/chat/api/reference/rest/v1/cards#action) that runs a custom function, like calling an API.\n\nThe `Image` widget has the following limitations:\n\n- Only PNG and JPG images are supported.\n- The host URL must be `HTTPS`.\n- To ensure performant cards, maximum recommended image size is 2MB.\n\nThe following is a card consisting of an `Image` widget. It displays the\nGoogle Chat developer documentation landing page image. When users click the\nimage, the Google Chat developer documentation opens in a new tab.\n\n### Add an image component\n\nThe `Image` widget is an image with limited styling. An\n[`imageCompent` widget](/workspace/chat/api/reference/rest/v1/cards#imagecomponent)\nlets you apply `cropStyle` and `borderStyle` to an image.\n\nThe following example shows two images in a grid where one of the images is\ncropped:\n\nYou can adjust the shape of an image component by applying a\n[`cropStyle`](/workspace/chat/api/reference/rest/v1/cards#imagecropstyle).\nThere are several shapes to apply to an image:\n\n- Use `SQUARE` to apply a square crop.\n- Use `CIRCLE` to apply a circular crop.\n- Use `RECTANGLE_CUSTOM` to apply a rectangular crop with a custom aspect ratio. For example, you can use `RECTANGLE_4_3` to apply a rectangular crop with a 4:3 aspect ratio.\n\nThe following example shows five images in a grid with a different `cropStyle`\napplied to each image:\n\n### Add an icon\n\nThe\n[`Icon` widget](/workspace/chat/api/reference/rest/v1/cards#textparagraph)\nrepresents either a\n[built-in](/workspace/chat/format-messages#builtinicons)\nicon or\n[custom](/workspace/chat/format-messages#customicons)\nicon. You add icons to cards to do any of the following:\n\n- Display a standalone icon.\n- Display an icon in front of related text, as part of a [`DecoratedText`](/workspace/chat/decorated-text) widget.\n- Display an icon as an interactive button, as part of a [`ButtonList`](/workspace/chat/button-list) widget.\n\nThe following is a card consisting of an `Icon` component with a built-in icon:\n\nThe following table lists the built-in icons that are available for card messages:\n\n|-------------------|---------------------|---------------------|------------------------------|\n| flight | **AIRPLANE** | bookmark | **BOOKMARK** |\n| directions_bus | **BUS** | directions_car | **CAR** |\n| schedule | **CLOCK** | confirmation_number | **CONFIRMATION_NUMBER_ICON** |\n| subject | **DESCRIPTION** | attach_money | **DOLLAR** |\n| mail | **EMAIL** | event_seat | **EVENT_SEAT** |\n| flight_land | **FLIGHT_ARRIVAL** | flight_takeoff | **FLIGHT_DEPARTURE** |\n| hotel | **HOTEL** | grade | **HOTEL_ROOM_TYPE** |\n| insert_invitation | **INVITE** | location_on | **MAP_PIN** |\n| card_membership | **MEMBERSHIP** | people | **MULTIPLE_PEOPLE** |\n| person | **PERSON** | local_phone | **PHONE** |\n| restaurant | **RESTAURANT_ICON** | shopping_cart | **SHOPPING_CART** |\n| grade | **STAR** | store | **STORE** |\n| local_play | **TICKET** | train | **TRAIN** |\n| videocam | **VIDEO_CAMERA** | play_circle_filled | **VIDEO_PLAY** |\n\nAdd text to a card\n------------------\n\nThis section explains how to add and format text in a card.\n\n### Add a paragraph of formatted text\n\nThe\n[`TextParagraph` widget](/workspace/chat/api/reference/rest/v1/cards#textparagraph)\ndisplays a paragraph of text with optional HTML formatting. When setting\nthe text content of these widgets, just include the corresponding HTML tags.\nFor more information about which HTML tags are supported, see\n[Format text that appears in cards](/workspace/chat/format-messages#card-formatting).\n\nFor example, the following formatting is available for paragraph text:\n\n- Display bold, underlined, or italicized text with HTML `\u003cb\u003e`, `\u003cu\u003e`, `\u003ci\u003e` tags.\n- Link to websites with HTML `\u003ca href=\"https://www.google.com\"\u003ehyperlinks\u003c/a\u003e`.\n- Add some color with HTML `\u003cfont color=\"#ea9999\"\u003efont tags\u003c/font\u003e`.\n\nEach `TextParagraph` widget renders as a new paragraph, and can be thought of\nas similar to an HTML `\u003cp\u003e` tag.\n\nThe following is a card consisting of two `TextParagraph` widgets used to\ndisplay two paragraphs with simple HTML formatting:\n\n#### Add a collapsible text paragraph\n\nThe collapsible text paragraphs let users reveal more information on demand.\nThis widget is perfect for presenting lengthy content or additional details that\ncan be explored when selected, creating a dynamic and interactive user\nexperience.\n\n### Display text with decorative elements\n\nThe\n[`DecoratedText` widget](/workspace/chat/api/reference/rest/v1/cards#DecoratedText)\ndisplays text with optional layout and capabilities. For example:\n\n- Display an `icon` in front of the text with `startIcon`.\n- Show a title before the text with `topLabel`.\n- Add a clickable button with `button` or switchable toggle with `switchControl`.\n\nUse the `DecoratedText` widget when you need to present information in an\neasy-to-consume and interactive way. The widget is perfect for use cases such as\ncontact cards, order status updates, and work ticket notifications.\n\nThe `DecoratedText` widget supports simple text HTML formatting. When setting\nthe text content of these widgets, just include the corresponding HTML tags. For\nmore information about which HTML tags are supported, see\n[Card text formatting](/workspace/chat/format-messages#view_text_formatting_sent_in_a_message).\n\nThe following is a card consisting of a `DecoratedText` widget used to display\ncontact details, such as email address, online status, phone number, and\nwebsite:\n\nTroubleshoot\n------------\n\n\nWhen a Google Chat app or\n[card](/workspace/chat/create-messages#create) returns an error, the\nChat interface surfaces a message saying \"Something went wrong.\"\nor \"Unable to process your request.\" Sometimes the Chat UI\ndoesn't display any error message, but the Chat app or\ncard produces an unexpected result; for example, a card message might not\nappear.\n\n\nAlthough an error message might not display in the Chat UI,\ndescriptive error messages and log data are available to help you fix errors\nwhen error logging for Chat apps is turned on. For help viewing,\ndebugging, and fixing errors, see\n[Troubleshoot and fix Google Chat errors](/workspace/chat/troubleshoot).\n\nRelated topics\n--------------\n\n- [View Chat app samples](/workspace/chat/samples) that use cards.\n- [`Image`](/workspace/chat/api/reference/rest/v1/cards#image)\n- [`imageCompent`](/workspace/chat/api/reference/rest/v1/cards#imagecomponent)\n- [`cropStyle`](/workspace/chat/api/reference/rest/v1/cards#imagecropstyle)\n- [`Icon`](/workspace/chat/api/reference/rest/v1/cards#textparagraph)\n- [`TextParagraph`](/workspace/chat/api/reference/rest/v1/cards#textparagraph)\n- [`DecoratedText`](/workspace/chat/api/reference/rest/v1/cards#DecoratedText)"]]