Class Carousel

  • Carousel displays a list of widgets in a slideshow format with navigation buttons.

  • Carousels are available for Google Workspace add-ons and Google Chat apps.

  • TheaddCarouselCard(card) method is used to add a card to the carousel.

Carousel

Carousel, also known as slider, rotates and displays a list of widgets in a slideshow format,with buttons navigating to the previous or next widget.

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

constcarousel=CardService.newCarousel().addCarouselCard(CardService.newCarouselCard().addWidget(CardService.newTextParagraph().setText('The first text paragraph in carousel'))).addCarouselCard(CardService.newCarouselCard().addWidget(CardService.newTextParagraph().setText('The second text paragraph in carousel'))).addCarouselCard(CardService.newCarouselCard().addWidget(CardService.newTextParagraph().setText('The third text paragraph in carousel')))

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

Methods

MethodReturn typeBrief description
addCarouselCard(card)CarouselAdds a carousel card.
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

addCarouselCard(card)

Adds a carousel card.

constcarousel=CardService.newCarousel().addCarouselCard(CardService.newCarouselCard().addWidget(CardService.newTextParagraph().setText('The first text paragraph in carousel')));

Parameters

NameTypeDescription
cardCarouselCardThe carousel card to add.

Return

Carousel — This object, for chaining.


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.