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.
Card builder
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
!Example contact
card
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
Inherited Members
com.google.protobuf.GeneratedMessageV3.<ListT>makeMutableCopy(ListT)
com.google.protobuf.GeneratedMessageV3.<ListT>makeMutableCopy(ListT,int)
com.google.protobuf.GeneratedMessageV3.<T>emptyList(java.lang.Class<T>)
com.google.protobuf.GeneratedMessageV3.internalGetMapFieldReflection(int)
Static Fields
CARD_ACTIONS_FIELD_NUMBER
public static final int CARD_ACTIONS_FIELD_NUMBER
Field Value |
---|
Type | Description |
int | |
DISPLAY_STYLE_FIELD_NUMBER
public static final int DISPLAY_STYLE_FIELD_NUMBER
Field Value |
---|
Type | Description |
int | |
public static final int FIXED_FOOTER_FIELD_NUMBER
Field Value |
---|
Type | Description |
int | |
public static final int HEADER_FIELD_NUMBER
Field Value |
---|
Type | Description |
int | |
NAME_FIELD_NUMBER
public static final int NAME_FIELD_NUMBER
Field Value |
---|
Type | Description |
int | |
public static final int PEEK_CARD_HEADER_FIELD_NUMBER
Field Value |
---|
Type | Description |
int | |
SECTIONS_FIELD_NUMBER
public static final int SECTIONS_FIELD_NUMBER
Field Value |
---|
Type | Description |
int | |
SECTION_DIVIDER_STYLE_FIELD_NUMBER
public static final int SECTION_DIVIDER_STYLE_FIELD_NUMBER
Field Value |
---|
Type | Description |
int | |
Static Methods
getDefaultInstance()
public static Card getDefaultInstance()
Returns |
---|
Type | Description |
Card | |
getDescriptor()
public static final Descriptors.Descriptor getDescriptor()
newBuilder()
public static Card.Builder newBuilder()
newBuilder(Card prototype)
public static Card.Builder newBuilder(Card prototype)
Parameter |
---|
Name | Description |
prototype | Card
|
public static Card parseDelimitedFrom(InputStream input)
Returns |
---|
Type | Description |
Card | |
public static Card parseDelimitedFrom(InputStream input, ExtensionRegistryLite extensionRegistry)
Returns |
---|
Type | Description |
Card | |
parseFrom(byte[] data)
public static Card parseFrom(byte[] data)
Parameter |
---|
Name | Description |
data | byte[]
|
Returns |
---|
Type | Description |
Card | |
parseFrom(byte[] data, ExtensionRegistryLite extensionRegistry)
public static Card parseFrom(byte[] data, ExtensionRegistryLite extensionRegistry)
Returns |
---|
Type | Description |
Card | |
parseFrom(ByteString data)
public static Card parseFrom(ByteString data)
Returns |
---|
Type | Description |
Card | |
parseFrom(ByteString data, ExtensionRegistryLite extensionRegistry)
public static Card parseFrom(ByteString data, ExtensionRegistryLite extensionRegistry)
Returns |
---|
Type | Description |
Card | |
public static Card parseFrom(CodedInputStream input)
Returns |
---|
Type | Description |
Card | |
public static Card parseFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry)
Returns |
---|
Type | Description |
Card | |
public static Card parseFrom(InputStream input)
Returns |
---|
Type | Description |
Card | |
public static Card parseFrom(InputStream input, ExtensionRegistryLite extensionRegistry)
Returns |
---|
Type | Description |
Card | |
parseFrom(ByteBuffer data)
public static Card parseFrom(ByteBuffer data)
Returns |
---|
Type | Description |
Card | |
parseFrom(ByteBuffer data, ExtensionRegistryLite extensionRegistry)
public static Card parseFrom(ByteBuffer data, ExtensionRegistryLite extensionRegistry)
Returns |
---|
Type | Description |
Card | |
parser()
public static Parser<Card> parser()
Methods
equals(Object obj)
public boolean equals(Object obj)
Parameter |
---|
Name | Description |
obj | Object
|
Overrides
getCardActions(int index)
public Card.CardAction getCardActions(int index)
The card's actions. Actions are added to the card's toolbar menu.
Google Workspace
Add-ons:
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;
Parameter |
---|
Name | Description |
index | int
|
getCardActionsCount()
public int getCardActionsCount()
The card's actions. Actions are added to the card's toolbar menu.
Google Workspace
Add-ons:
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;
Returns |
---|
Type | Description |
int | |
getCardActionsList()
public List<Card.CardAction> getCardActionsList()
The card's actions. Actions are added to the card's toolbar menu.
Google Workspace
Add-ons:
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.
Google Workspace
Add-ons:
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;
Parameter |
---|
Name | Description |
index | int
|
getCardActionsOrBuilderList()
public List<? extends Card.CardActionOrBuilder> getCardActionsOrBuilderList()
The card's actions. Actions are added to the card's toolbar menu.
Google Workspace
Add-ons:
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;
Returns |
---|
Type | Description |
List<? extends com.google.apps.card.v1.Card.CardActionOrBuilder> | |
getDefaultInstanceForType()
public Card getDefaultInstanceForType()
Returns |
---|
Type | Description |
Card | |
getDisplayStyle()
public Card.DisplayStyle getDisplayStyle()
In Google Workspace Add-ons, sets the display properties of the
peekCardHeader
.
Google Workspace
Add-ons:
.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 Workspace
Add-ons:
.google.apps.card.v1.Card.DisplayStyle display_style = 6;
Returns |
---|
Type | Description |
int | The enum numeric value on the wire for displayStyle.
|
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;
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;
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;
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()
Returns |
---|
Type | Description |
String | The name.
|
getNameBytes()
public ByteString getNameBytes()
Returns |
---|
Type | Description |
ByteString | The bytes for name.
|
getParserForType()
public Parser<Card> getParserForType()
Overrides
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 Workspace
Add-ons:
.google.apps.card.v1.Card.CardHeader peek_card_header = 7;
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 Workspace
Add-ons:
.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;
Returns |
---|
Type | Description |
int | The enum numeric value on the wire for sectionDividerStyle.
|
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;
Parameter |
---|
Name | Description |
index | int
|
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;
Returns |
---|
Type | Description |
int | |
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;
Parameter |
---|
Name | Description |
index | int
|
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;
Returns |
---|
Type | Description |
List<? extends com.google.apps.card.v1.Card.SectionOrBuilder> | |
getSerializedSize()
public int getSerializedSize()
Returns |
---|
Type | Description |
int | |
Overrides
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;
Returns |
---|
Type | Description |
boolean | Whether the fixedFooter field is set.
|
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;
Returns |
---|
Type | Description |
boolean | Whether the header field is set.
|
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 Workspace
Add-ons:
.google.apps.card.v1.Card.CardHeader peek_card_header = 7;
Returns |
---|
Type | Description |
boolean | Whether the peekCardHeader field is set.
|
hashCode()
Returns |
---|
Type | Description |
int | |
Overrides
internalGetFieldAccessorTable()
protected GeneratedMessageV3.FieldAccessorTable internalGetFieldAccessorTable()
Overrides
isInitialized()
public final boolean isInitialized()
Overrides
newBuilderForType()
public Card.Builder newBuilderForType()
newBuilderForType(GeneratedMessageV3.BuilderParent parent)
protected Card.Builder newBuilderForType(GeneratedMessageV3.BuilderParent parent)
Overrides
newInstance(GeneratedMessageV3.UnusedPrivateParameter unused)
protected Object newInstance(GeneratedMessageV3.UnusedPrivateParameter unused)
Overrides
toBuilder()
public Card.Builder toBuilder()
writeTo(CodedOutputStream output)
public void writeTo(CodedOutputStream output)
Overrides