Class TextParagraph

  • A TextParagraph is a widget that displays text and supports basic HTML formatting.

  • It is available for Google Workspace add-ons and Google Chat apps.

  • Key methods includesetMaxLines() to set the maximum lines displayed andsetText() to set the paragraph's text.

  • ThesetMaxLines() method can hide excess content behind a "show more" button if the text exceeds the limit.

TextParagraph

A widget that displays text and supportsbasic HTML formatting.

Available for Google Workspace add-ons and Google Chat apps.

consttextParagraph=CardService.newTextParagraph().setText('This is a text paragraph widget. Multiple lines are allowed if needed.',);

Methods

MethodReturn typeBrief description
addEventAction(eventAction)WidgetAdds the event action that can be performed on the widget.
setId(id)WidgetSets the unique ID assigned that's used to identify the widget to be mutated.
setMaxLines(maxLines)TextParagraphSets the maximum number of lines of text that are displayed in the widget.
setText(text)TextParagraphSets the text of the paragraph.
setVisibility(visibility)WidgetSets the visibility of the widget.

Detailed documentation

addEventAction(eventAction)

Adds the event action that can be performed on the widget.

Parameters

NameTypeDescription
eventActionEventActionTheEventAction to be added.

Return

Widget — The Object, for chaining.


setId(id)

Sets the unique ID assigned that's used to identify the widget to be mutated. Widget mutationis only supported in Add-Ons.

Parameters

NameTypeDescription
idStringThe id of the widget, with a limit of 64 characters and in format of `[a-zA-Z0-9-]+`.

Return

Widget — This object, for chaining.


setMaxLines(maxLines)

Sets the maximum number of lines of text that are displayed in the widget. If the text exceedsthe specified maximum number of lines, the excess content is concealed behind a "show more"button. If the text is equal or shorter than the specified maximum number of lines, a "showmore" button isn't displayed.

Available for Google Chat apps. In developer preview for Google Workspace add-ons.

Developer Preview: Available as part of theGoogle Workspace Developer Preview Program, which grants early access to certain features.

consttextParagraph=CardService.newTextParagraph().setText('This is a text paragraph widget. Multiple lines are allowed if needed.',).setMaxLines(1);

Parameters

NameTypeDescription
maxLinesIntegerThe maximum number of lines of text that are displayed.

Return

TextParagraph — This object, for chaining.


setText(text)

Sets the text of the paragraph. Required.

Parameters

NameTypeDescription
textStringThe text to display.

Return

TextParagraph — This object, for chaining.


setVisibility(visibility)

Sets the visibility of the widget. The default value is `VISIBLE`.

Parameters

NameTypeDescription
visibilityVisibilityTheVisibility of the widget.

Return

Widget — The Object, for chaining.

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-12-03 UTC.