public
final
class
Card
extends
GeneratedMessageV3
implements
CardOrBuilder
A card interface displayed in a Google Chat message or Google Workspace Add-on.
Cards support a defined layout, interactive UI elements like buttons, and rich media like images. Use cards to present detailed information, gather information from users, and guide users to take a next step.
To learn how to build cards, see the following documentation:
- For Google Chat apps, see Design dynamic, interactive, and consistent UIs with cards .
-
For Google Workspace Add-ons, see Card-based interfaces .
Example: Card message for a Google Chat app
To create the sample card message in Google Chat, use the following JSON:
<code><code> { "cardsV2": [ { "cardId": "unique-card-id", "card": { "header": { "title": "Sasha", "subtitle": "Software Engineer", "imageUrl": "https://developers.google.com/chat/images/quickstart-app-avatar.png", "imageType": "CIRCLE", "imageAltText": "Avatar for Sasha", }, "sections": [ { "header": "Contact Info", "collapsible": true, "uncollapsibleWidgetsCount": 1, "widgets": [ { "decoratedText": { "startIcon": { "knownIcon": "EMAIL", }, "text": "sasha@example.com", } }, { "decoratedText": { "startIcon": { "knownIcon": "PERSON", }, "text": "<font color=\"#80e27e\">Online</font>", }, }, { "decoratedText": { "startIcon": { "knownIcon": "PHONE", }, "text": "+1 (555) 555-1234", } }, { "buttonList": { "buttons": [ { "text": "Share", "onClick": { "openLink": { "url": "https://example.com/share", } } }, { "text": "Edit", "onClick": { "action": { "function": "goToView", "parameters": [ { "key": "viewType", "value": "EDIT", } ], } } }, ], } }, ], }, ], }, } ], } </code></code>
Protobuf type google.apps.card.v1.Card
Inheritance
Object > AbstractMessageLite<MessageType,BuilderType> > AbstractMessage > GeneratedMessageV3 > CardImplements
CardOrBuilderStatic Fields
CARD_ACTIONS_FIELD_NUMBER
public
static
final
int
CARD_ACTIONS_FIELD_NUMBER
DISPLAY_STYLE_FIELD_NUMBER
public
static
final
int
DISPLAY_STYLE_FIELD_NUMBER
FIXED_FOOTER_FIELD_NUMBER
public
static
final
int
FIXED_FOOTER_FIELD_NUMBER
HEADER_FIELD_NUMBER
public
static
final
int
HEADER_FIELD_NUMBER
NAME_FIELD_NUMBER
public
static
final
int
NAME_FIELD_NUMBER
PEEK_CARD_HEADER_FIELD_NUMBER
public
static
final
int
PEEK_CARD_HEADER_FIELD_NUMBER
SECTIONS_FIELD_NUMBER
public
static
final
int
SECTIONS_FIELD_NUMBER
SECTION_DIVIDER_STYLE_FIELD_NUMBER
public
static
final
int
SECTION_DIVIDER_STYLE_FIELD_NUMBER
Static Methods
getDefaultInstance()
public
static
Card
getDefaultInstance
()
getDescriptor()
public
static
final
Descriptors
.
Descriptor
getDescriptor
()
newBuilder()
public
static
Card
.
Builder
newBuilder
()
newBuilder(Card prototype)
public
static
Card
.
Builder
newBuilder
(
Card
prototype
)
parseDelimitedFrom(InputStream input)
public
static
Card
parseDelimitedFrom
(
InputStream
input
)
parseDelimitedFrom(InputStream input, ExtensionRegistryLite extensionRegistry)
public
static
Card
parseDelimitedFrom
(
InputStream
input
,
ExtensionRegistryLite
extensionRegistry
)
parseFrom(byte[] data)
public
static
Card
parseFrom
(
byte
[]
data
)
data
byte
[]
parseFrom(byte[] data, ExtensionRegistryLite extensionRegistry)
public
static
Card
parseFrom
(
byte
[]
data
,
ExtensionRegistryLite
extensionRegistry
)
parseFrom(ByteString data)
public
static
Card
parseFrom
(
ByteString
data
)
parseFrom(ByteString data, ExtensionRegistryLite extensionRegistry)
public
static
Card
parseFrom
(
ByteString
data
,
ExtensionRegistryLite
extensionRegistry
)
parseFrom(CodedInputStream input)
public
static
Card
parseFrom
(
CodedInputStream
input
)
parseFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry)
public
static
Card
parseFrom
(
CodedInputStream
input
,
ExtensionRegistryLite
extensionRegistry
)
parseFrom(InputStream input)
public
static
Card
parseFrom
(
InputStream
input
)
parseFrom(InputStream input, ExtensionRegistryLite extensionRegistry)
public
static
Card
parseFrom
(
InputStream
input
,
ExtensionRegistryLite
extensionRegistry
)
parseFrom(ByteBuffer data)
public
static
Card
parseFrom
(
ByteBuffer
data
)
parseFrom(ByteBuffer data, ExtensionRegistryLite extensionRegistry)
public
static
Card
parseFrom
(
ByteBuffer
data
,
ExtensionRegistryLite
extensionRegistry
)
parser()
public
static
Parser<Card>
parser
()
Methods
equals(Object obj)
public
boolean
equals
(
Object
obj
)
getCardActions(int index)
public
Card
.
CardAction
getCardActions
(
int
index
)
The card's actions. Actions are added to the card's toolbar menu.
For example, the following JSON constructs a card action menu with Settings
and Send Feedback
options:
<code><code>
"card_actions": [
{
"actionLabel": "Settings",
"onClick": {
"action": {
"functionName": "goToView",
"parameters": [
{
"key": "viewType",
"value": "SETTING"
}
],
"loadIndicator": "LoadIndicator.SPINNER"
}
}
},
{
"actionLabel": "Send Feedback",
"onClick": {
"openLink": {
"url": "https://example.com/feedback"
}
}
}
]
</code></code>
repeated .google.apps.card.v1.Card.CardAction card_actions = 3;
getCardActionsCount()
public
int
getCardActionsCount
()
The card's actions. Actions are added to the card's toolbar menu.
For example, the following JSON constructs a card action menu with Settings
and Send Feedback
options:
<code><code>
"card_actions": [
{
"actionLabel": "Settings",
"onClick": {
"action": {
"functionName": "goToView",
"parameters": [
{
"key": "viewType",
"value": "SETTING"
}
],
"loadIndicator": "LoadIndicator.SPINNER"
}
}
},
{
"actionLabel": "Send Feedback",
"onClick": {
"openLink": {
"url": "https://example.com/feedback"
}
}
}
]
</code></code>
repeated .google.apps.card.v1.Card.CardAction card_actions = 3;
getCardActionsList()
public
List<Card
.
CardAction
>
getCardActionsList
()
The card's actions. Actions are added to the card's toolbar menu.
For example, the following JSON constructs a card action menu with Settings
and Send Feedback
options:
<code><code>
"card_actions": [
{
"actionLabel": "Settings",
"onClick": {
"action": {
"functionName": "goToView",
"parameters": [
{
"key": "viewType",
"value": "SETTING"
}
],
"loadIndicator": "LoadIndicator.SPINNER"
}
}
},
{
"actionLabel": "Send Feedback",
"onClick": {
"openLink": {
"url": "https://example.com/feedback"
}
}
}
]
</code></code>
repeated .google.apps.card.v1.Card.CardAction card_actions = 3;
getCardActionsOrBuilder(int index)
public
Card
.
CardActionOrBuilder
getCardActionsOrBuilder
(
int
index
)
The card's actions. Actions are added to the card's toolbar menu.
For example, the following JSON constructs a card action menu with Settings
and Send Feedback
options:
<code><code>
"card_actions": [
{
"actionLabel": "Settings",
"onClick": {
"action": {
"functionName": "goToView",
"parameters": [
{
"key": "viewType",
"value": "SETTING"
}
],
"loadIndicator": "LoadIndicator.SPINNER"
}
}
},
{
"actionLabel": "Send Feedback",
"onClick": {
"openLink": {
"url": "https://example.com/feedback"
}
}
}
]
</code></code>
repeated .google.apps.card.v1.Card.CardAction card_actions = 3;
getCardActionsOrBuilderList()
public
List
< ?
extends
Card
.
CardActionOrBuilder
>
getCardActionsOrBuilderList
()
The card's actions. Actions are added to the card's toolbar menu.
For example, the following JSON constructs a card action menu with Settings
and Send Feedback
options:
<code><code>
"card_actions": [
{
"actionLabel": "Settings",
"onClick": {
"action": {
"functionName": "goToView",
"parameters": [
{
"key": "viewType",
"value": "SETTING"
}
],
"loadIndicator": "LoadIndicator.SPINNER"
}
}
},
{
"actionLabel": "Send Feedback",
"onClick": {
"openLink": {
"url": "https://example.com/feedback"
}
}
}
]
</code></code>
repeated .google.apps.card.v1.Card.CardAction card_actions = 3;
getDefaultInstanceForType()
public
Card
getDefaultInstanceForType
()
getDisplayStyle()
public
Card
.
DisplayStyle
getDisplayStyle
()
In Google Workspace Add-ons, sets the display properties of the peekCardHeader
.
.google.apps.card.v1.Card.DisplayStyle display_style = 6;
getDisplayStyleValue()
public
int
getDisplayStyleValue
()
In Google Workspace Add-ons, sets the display properties of the peekCardHeader
.
.google.apps.card.v1.Card.DisplayStyle display_style = 6;
getFixedFooter()
public
Card
.
CardFixedFooter
getFixedFooter
()
The fixed footer shown at the bottom of this card.
Setting fixedFooter
without specifying a primaryButton
or a secondaryButton
causes an error. For Chat apps, you can use fixed footers
in dialogs
, but not card
messages
.
Google Workspace Add-ons and Chat apps :
.google.apps.card.v1.Card.CardFixedFooter fixed_footer = 5;
getFixedFooterOrBuilder()
public
Card
.
CardFixedFooterOrBuilder
getFixedFooterOrBuilder
()
The fixed footer shown at the bottom of this card.
Setting fixedFooter
without specifying a primaryButton
or a secondaryButton
causes an error. For Chat apps, you can use fixed footers
in dialogs
, but not card
messages
.
Google Workspace Add-ons and Chat apps :
.google.apps.card.v1.Card.CardFixedFooter fixed_footer = 5;
getHeader()
public
Card
.
CardHeader
getHeader
()
The header of the card. A header usually contains a leading image and a title. Headers always appear at the top of a card.
.google.apps.card.v1.Card.CardHeader header = 1;
getHeaderOrBuilder()
public
Card
.
CardHeaderOrBuilder
getHeaderOrBuilder
()
The header of the card. A header usually contains a leading image and a title. Headers always appear at the top of a card.
.google.apps.card.v1.Card.CardHeader header = 1;
getName()
public
String
getName
()
Name of the card. Used as a card identifier in card navigation.
string name = 4;
getNameBytes()
public
ByteString
getNameBytes
()
Name of the card. Used as a card identifier in card navigation.
string name = 4;
getParserForType()
public
Parser<Card>
getParserForType
()
getPeekCardHeader()
public
Card
.
CardHeader
getPeekCardHeader
()
When displaying contextual content, the peek card header acts as a placeholder so that the user can navigate forward between the homepage cards and the contextual cards.
.google.apps.card.v1.Card.CardHeader peek_card_header = 7;
getPeekCardHeaderOrBuilder()
public
Card
.
CardHeaderOrBuilder
getPeekCardHeaderOrBuilder
()
When displaying contextual content, the peek card header acts as a placeholder so that the user can navigate forward between the homepage cards and the contextual cards.
.google.apps.card.v1.Card.CardHeader peek_card_header = 7;
getSectionDividerStyle()
public
Card
.
DividerStyle
getSectionDividerStyle
()
The divider style between sections.
.google.apps.card.v1.Card.DividerStyle section_divider_style = 9;
getSectionDividerStyleValue()
public
int
getSectionDividerStyleValue
()
The divider style between sections.
.google.apps.card.v1.Card.DividerStyle section_divider_style = 9;
getSections(int index)
public
Card
.
Section
getSections
(
int
index
)
Contains a collection of widgets. Each section has its own, optional header. Sections are visually separated by a line divider. For an example in Google Chat apps, see Card section .
repeated .google.apps.card.v1.Card.Section sections = 2;
getSectionsCount()
public
int
getSectionsCount
()
Contains a collection of widgets. Each section has its own, optional header. Sections are visually separated by a line divider. For an example in Google Chat apps, see Card section .
repeated .google.apps.card.v1.Card.Section sections = 2;
getSectionsList()
public
List<Card
.
Section
>
getSectionsList
()
Contains a collection of widgets. Each section has its own, optional header. Sections are visually separated by a line divider. For an example in Google Chat apps, see Card section .
repeated .google.apps.card.v1.Card.Section sections = 2;
getSectionsOrBuilder(int index)
public
Card
.
SectionOrBuilder
getSectionsOrBuilder
(
int
index
)
Contains a collection of widgets. Each section has its own, optional header. Sections are visually separated by a line divider. For an example in Google Chat apps, see Card section .
repeated .google.apps.card.v1.Card.Section sections = 2;
getSectionsOrBuilderList()
public
List
< ?
extends
Card
.
SectionOrBuilder
>
getSectionsOrBuilderList
()
Contains a collection of widgets. Each section has its own, optional header. Sections are visually separated by a line divider. For an example in Google Chat apps, see Card section .
repeated .google.apps.card.v1.Card.Section sections = 2;
getSerializedSize()
public
int
getSerializedSize
()
hasFixedFooter()
public
boolean
hasFixedFooter
()
The fixed footer shown at the bottom of this card.
Setting fixedFooter
without specifying a primaryButton
or a secondaryButton
causes an error. For Chat apps, you can use fixed footers
in dialogs
, but not card
messages
.
Google Workspace Add-ons and Chat apps :
.google.apps.card.v1.Card.CardFixedFooter fixed_footer = 5;
hasHeader()
public
boolean
hasHeader
()
The header of the card. A header usually contains a leading image and a title. Headers always appear at the top of a card.
.google.apps.card.v1.Card.CardHeader header = 1;
hasPeekCardHeader()
public
boolean
hasPeekCardHeader
()
When displaying contextual content, the peek card header acts as a placeholder so that the user can navigate forward between the homepage cards and the contextual cards.
.google.apps.card.v1.Card.CardHeader peek_card_header = 7;
hashCode()
public
int
hashCode
()
internalGetFieldAccessorTable()
protected
GeneratedMessageV3
.
FieldAccessorTable
internalGetFieldAccessorTable
()
isInitialized()
public
final
boolean
isInitialized
()
newBuilderForType()
public
Card
.
Builder
newBuilderForType
()
newBuilderForType(GeneratedMessageV3.BuilderParent parent)
protected
Card
.
Builder
newBuilderForType
(
GeneratedMessageV3
.
BuilderParent
parent
)
newInstance(GeneratedMessageV3.UnusedPrivateParameter unused)
protected
Object
newInstance
(
GeneratedMessageV3
.
UnusedPrivateParameter
unused
)
toBuilder()
public
Card
.
Builder
toBuilder
()
writeTo(CodedOutputStream output)
public
void
writeTo
(
CodedOutputStream
output
)