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 include setMaxLines() to set the maximum lines displayed and setText() to set the paragraph's text.

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

Text Paragraph

A widget that displays text and supports basic HTML formatting .

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

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

Methods

Method Return type Brief description
Widget Adds the event action that can be performed on the widget.
Widget Sets the unique ID assigned that's used to identify the widget to be mutated.
Text Paragraph Sets the maximum number of lines of text that are displayed in the widget.
Text Paragraph Sets the text of the paragraph.
Widget Sets the visibility of the widget.

Detailed documentation

add Event Action(eventAction)

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

Parameters

Name Type Description
event Action
Event Action The Event Action to be added.

Return

Widget — The Object, for chaining.


set Id(id)

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

Parameters

Name Type Description
id
String The id of the widget, with a limit of 64 characters and in format of `[a-zA-Z0-9-]+`.

Return

Widget — This object, for chaining.


set Max Lines(maxLines)

Sets the maximum number of lines of text that are displayed in the widget. If the text exceeds the 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 "show more" button isn't displayed.

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

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

Parameters

Name Type Description
max Lines
Integer The maximum number of lines of text that are displayed.

Return

Text Paragraph — This object, for chaining.


set Text(text)

Sets the text of the paragraph. Required.

Parameters

Name Type Description
text
String The text to display.

Return

Text Paragraph — This object, for chaining.


set Visibility(visibility)

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

Parameters

Name Type Description
visibility
Visibility The Visibility of the widget.

Return

Widget — The Object, for chaining.

Design a Mobile Site
View Site in Mobile | Classic
Share by: