Class Divider

  • A divider creates a horizontal line in an add-on card.

  • Use thenewDivider() method fromCardService to add a divider.

  • The provided code sample demonstrates how to build a card with paragraphs separated by a divider.

Divider

A horizontal divider. To add a divider to your add-on card, use thenewDivider()method withinCardService. For example, the following sample builds a simple card with 2paragraphs separated by a divider.

functionbuildCard(){constcardSection1TextParagraph1=CardService.newTextParagraph().setText('Hello world!');constcardSection1Divider1=CardService.newDivider();constcardSection1TextParagraph2=CardService.newTextParagraph().setText('Hello world!');constcardSection1=CardService.newCardSection().addWidget(cardSection1TextParagraph1).addWidget(cardSection1Divider1).addWidget(cardSection1TextParagraph2);constcard=CardService.newCardBuilder().addSection(cardSection1).build();returncard;}

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.
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.


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.