The CardSection
widget is a high-level container within a card. You use card sections to group widgets within a card. For each card section, you can include a header and one or more widgets.
You can include sections for card messages and dialogs.
Example
The following image displays a card consisting of a CardSection
component.

CardSection
displaying a header and two TextParagraph
widgets. The second text paragraph is collapsed.
Here's the card's JSON:
JSON
{
"cardsV2": [
{
"cardId": "card_one",
"card": {
"sections": [
{
"header": "List of Collapsible Text Paragraphs",
"collapsible": true,
"uncollapsibleWidgetsCount": 1,
"widgets": [
{
"textParagraph": {
"text": "This is a normal test string 1",
}
},
{
"textParagraph": {
"text": "This is a normal test string 2",
}
}
]
}]
}
}
]
}
JSON representation and fields
JSON representation |
---|
{
"header": string,
"widgets": [
{
object (
|
Fields | |
---|---|
header
|
Text that appears at the top of a section. Supports simple HTML formatted text. For more information about formatting text, see Formatting text in Google Chat apps and Formatting text in Google Workspace Add-ons. |
widgets[]
|
All the widgets in the section. Must contain at least one widget. |
collapsible
|
Indicates whether this section is collapsible. Collapsible sections hide some or all widgets, but users can expand the section to reveal the hidden widgets by clicking Show more. Users can hide the widgets again by clicking Show less.
To determine which widgets are hidden, specify
|
uncollapsibleWidgetsCount
|
The number of uncollapsible widgets which remain visible even when a section is collapsed.
For example, when a section contains five widgets and the
|
Widget
Each card is made up of widgets.
A widget is a composite object that can represent one of text, images, buttons, and other object types.
JSON representation |
---|
{ "horizontalAlignment": enum ( |
Fields | |
---|---|
horizontalAlignment
|
Specifies whether widgets align to the left, right, or center of a column. |
Union field
data . A widget can only have one of the following items. You can use multiple widget fields to display more items.
data
can be only one of the following:
|
|
textParagraph
|
Displays a text paragraph. Supports simple HTML formatted text. For more information about formatting text, see Formatting text in Google Chat apps and Formatting text in Google Workspace Add-ons. For example, the following JSON creates a bolded text:
|
image
|
Displays an image. For example, the following JSON creates an image with alternative text:
|
decoratedText
|
Displays a decorated text item. For example, the following JSON creates a decorated text widget showing email address:
|
buttonList
|
A list of buttons. For example, the following JSON creates two buttons. The first is a blue text button and the second is an image button that opens a link:
|
textInput
|
Displays a text box that users can type into. For example, the following JSON creates a text input for an email address:
As another example, the following JSON creates a text input for a programming language with static suggestions:
|
selectionInput
|
Displays a selection control that lets users select items. Selection controls can be checkboxes, radio buttons, switches, or dropdown menus. For example, the following JSON creates a dropdown menu that lets users choose a size:
|
dateTimePicker
|
Displays a widget that lets users input a date, time, or date and time. For example, the following JSON creates a date time picker to schedule an appointment:
|
divider
|
Displays a horizontal line divider between widgets. For example, the following JSON creates a divider:
|
grid
|
Displays a grid with a collection of items. A grid supports any number of columns and items. The number of rows is determined by the upper bounds of the number items divided by the number of columns. A grid with 10 items and 2 columns has 5 rows. A grid with 11 items and 2 columns has 6 rows. For example, the following JSON creates a 2 column grid with a single item:
|
columns
|
Displays up to 2 columns.
To include more than 2 columns, or to use rows, use the
For example, the following JSON creates 2 columns that each contain text paragraphs:
|