If set, the button is filled with a solid background color and the font color changes to maintain contrast with the background color. For example, setting a blue background likely results in white text. If unset, the image background is white and the font color is blue. For red, green, and blue, the value of each field is afloatnumber that you can express in either of two ways: as a number between 0 and 255 divided by 255 (153/255), or as a value between 0 and 1 (0.6). 0 represents the absence of a color and 1 or 255/255 represent the full presence of that color on the RGB scale. Optionally setalpha, which sets a level of transparency using this equation:pixel color = alpha * (this color) + (1.0 - alpha) * (background color)Foralpha, a value of1corresponds with a solid color, and a value of0corresponds with a completely transparent color. For example, the following color represents a half transparent red:"color": { "red": 1, "green": 0, "blue": 0, "alpha": 0.5 }
Required. The action to perform when a user clicks the button, such as opening a hyperlink or running a custom function.
↳ disabled
bool
Iftrue, the button is displayed in an inactive state and doesn't respond to user actions.
↳ alt_text
string
The alternative text that's used for accessibility. Set descriptive text that lets users know what the button does. For example, if a button opens a hyperlink, you might write: "Opens a new browser tab and navigates to the Google Chat developer documentation athttps://developers.google.com/workspace/chat".
getText
The text displayed inside the button.
Returns
Type
Description
string
setText
The text displayed inside the button.
Parameter
Name
Description
var
string
Returns
Type
Description
$this
getIcon
The icon image. If bothiconandtextare set, then the icon appears
before the text.
If set, the button is filled with a solid background color and the font
color changes to maintain contrast with the background color. For example,
setting a blue background likely results in white text.
If unset, the image background is white and the font color is blue.
For red, green, and blue, the value of each field is afloatnumber that
you can express in either of two ways: as a number between 0 and 255
divided by 255 (153/255), or as a value between 0 and 1 (0.6). 0 represents
the absence of a color and 1 or 255/255 represent the full presence of that
color on the RGB scale.
Optionally setalpha, which sets a level of transparency using this
equation:
Foralpha, a value of1corresponds with a solid color, and a value of0corresponds with a completely transparent color.
For example, the following color represents a half transparent red:
If set, the button is filled with a solid background color and the font
color changes to maintain contrast with the background color. For example,
setting a blue background likely results in white text.
If unset, the image background is white and the font color is blue.
For red, green, and blue, the value of each field is afloatnumber that
you can express in either of two ways: as a number between 0 and 255
divided by 255 (153/255), or as a value between 0 and 1 (0.6). 0 represents
the absence of a color and 1 or 255/255 represent the full presence of that
color on the RGB scale.
Optionally setalpha, which sets a level of transparency using this
equation:
Foralpha, a value of1corresponds with a solid color, and a value of0corresponds with a completely transparent color.
For example, the following color represents a half transparent red:
Iftrue, the button is displayed in an inactive state and doesn't respond
to user actions.
Returns
Type
Description
bool
setDisabled
Iftrue, the button is displayed in an inactive state and doesn't respond
to user actions.
Parameter
Name
Description
var
bool
Returns
Type
Description
$this
getAltText
The alternative text that's used for accessibility.
Set descriptive text that lets users know what the button does. For
example, if a button opens a hyperlink, you might write: "Opens a new
browser tab and navigates to the Google Chat developer documentation athttps://developers.google.com/workspace/chat".
Returns
Type
Description
string
setAltText
The alternative text that's used for accessibility.
Set descriptive text that lets users know what the button does. For
example, if a button opens a hyperlink, you might write: "Opens a new
browser tab and navigates to the Google Chat developer documentation athttps://developers.google.com/workspace/chat".
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[],[],null,["# Google Apps Chat V1 Client - Class Button (0.12.0)\n\nVersion latestkeyboard_arrow_down\n\n- [0.12.0 (latest)](/php/docs/reference/apps-chat/latest/Card.V1.Button)\n- [0.11.2](/php/docs/reference/apps-chat/0.11.2/Card.V1.Button)\n- [0.10.0](/php/docs/reference/apps-chat/0.10.0/Card.V1.Button)\n- [0.9.0](/php/docs/reference/apps-chat/0.9.0/Card.V1.Button)\n- [0.8.1](/php/docs/reference/apps-chat/0.8.1/Card.V1.Button)\n- [0.7.2](/php/docs/reference/apps-chat/0.7.2/Card.V1.Button)\n- [0.6.1](/php/docs/reference/apps-chat/0.6.1/Card.V1.Button)\n- [0.5.0](/php/docs/reference/apps-chat/0.5.0/Card.V1.Button)\n- [0.4.0](/php/docs/reference/apps-chat/0.4.0/Card.V1.Button)\n- [0.3.0](/php/docs/reference/apps-chat/0.3.0/Card.V1.Button)\n- [0.2.0](/php/docs/reference/apps-chat/0.2.0/Card.V1.Button)\n- [0.1.4](/php/docs/reference/apps-chat/0.1.4/Card.V1.Button) \nReference documentation and code samples for the Google Apps Chat V1 Client class Button.\n\nA text, icon, or text and icon button that users can click. For an example in\nGoogle Chat apps, see\n[Add a\nbutton](https://developers.google.com/workspace/chat/design-interactive-card-dialog#add_a_button).\n\nTo make an image a clickable button, specify an\n[`Image`](/php/docs/reference/apps-chat/latest/Card.V1.Image) (not an\n[`ImageComponent`](/php/docs/reference/apps-chat/latest/Card.V1.ImageComponent)) and set an\n`onClick` action.\n[Google Workspace\nAdd-ons and Chat apps](https://developers.google.com/workspace/extend):\n\nGenerated from protobuf message `google.apps.card.v1.Button`\n\nNamespace\n---------\n\nGoogle \\\\ Apps \\\\ Card \\\\ V1\n\nMethods\n-------\n\n### __construct\n\nConstructor.\n\n### getText\n\nThe text displayed inside the button.\n\n### setText\n\nThe text displayed inside the button.\n\n### getIcon\n\nThe icon image. If both `icon` and `text` are set, then the icon appears\nbefore the text.\n\n### hasIcon\n\n### clearIcon\n\n### setIcon\n\nThe icon image. If both `icon` and `text` are set, then the icon appears\nbefore the text.\n\n### getColor\n\nIf set, the button is filled with a solid background color and the font\ncolor changes to maintain contrast with the background color. For example,\nsetting a blue background likely results in white text.\n\nIf unset, the image background is white and the font color is blue.\nFor red, green, and blue, the value of each field is a `float` number that\nyou can express in either of two ways: as a number between 0 and 255\ndivided by 255 (153/255), or as a value between 0 and 1 (0.6). 0 represents\nthe absence of a color and 1 or 255/255 represent the full presence of that\ncolor on the RGB scale.\nOptionally set `alpha`, which sets a level of transparency using this\nequation: \n\n pixel color = alpha * (this color) + (1.0 - alpha) * (background color)\n\nFor `alpha`, a value of `1` corresponds with a solid color, and a value of\n`0` corresponds with a completely transparent color.\nFor example, the following color represents a half transparent red: \n\n \"color\": {\n \"red\": 1,\n \"green\": 0,\n \"blue\": 0,\n \"alpha\": 0.5\n }\n\n### hasColor\n\n### clearColor\n\n### setColor\n\nIf set, the button is filled with a solid background color and the font\ncolor changes to maintain contrast with the background color. For example,\nsetting a blue background likely results in white text.\n\nIf unset, the image background is white and the font color is blue.\nFor red, green, and blue, the value of each field is a `float` number that\nyou can express in either of two ways: as a number between 0 and 255\ndivided by 255 (153/255), or as a value between 0 and 1 (0.6). 0 represents\nthe absence of a color and 1 or 255/255 represent the full presence of that\ncolor on the RGB scale.\nOptionally set `alpha`, which sets a level of transparency using this\nequation: \n\n pixel color = alpha * (this color) + (1.0 - alpha) * (background color)\n\nFor `alpha`, a value of `1` corresponds with a solid color, and a value of\n`0` corresponds with a completely transparent color.\nFor example, the following color represents a half transparent red: \n\n \"color\": {\n \"red\": 1,\n \"green\": 0,\n \"blue\": 0,\n \"alpha\": 0.5\n }\n\n### getOnClick\n\nRequired. The action to perform when a user clicks the button, such as\nopening a hyperlink or running a custom function.\n\n### hasOnClick\n\n### clearOnClick\n\n### setOnClick\n\nRequired. The action to perform when a user clicks the button, such as\nopening a hyperlink or running a custom function.\n\n### getDisabled\n\nIf `true`, the button is displayed in an inactive state and doesn't respond\nto user actions.\n\n### setDisabled\n\nIf `true`, the button is displayed in an inactive state and doesn't respond\nto user actions.\n\n### getAltText\n\nThe alternative text that's used for accessibility.\n\nSet descriptive text that lets users know what the button does. For\nexample, if a button opens a hyperlink, you might write: \"Opens a new\nbrowser tab and navigates to the Google Chat developer documentation at\n\u003chttps://developers.google.com/workspace/chat\u003e\".\n\n### setAltText\n\nThe alternative text that's used for accessibility.\n\nSet descriptive text that lets users know what the button does. For\nexample, if a button opens a hyperlink, you might write: \"Opens a new\nbrowser tab and navigates to the Google Chat developer documentation at\n\u003chttps://developers.google.com/workspace/chat\u003e\"."]]