CollapseControl

A customizable collapse and expand control.

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


> [!WARNING]
> **Developer Preview:** Available as part of the [Google Workspace Developer Preview Program](https://developers.google.com/workspace/preview), which grants early access to certain features.

<br />

```javascript
const collapseButton =
    CardService.newTextButton()
        .setTextButtonStyle(CardService.TextButtonStyle.BORDERLESS)
        .setText('Collapse');

const expandButton =
    CardService.newImageButton()
        .setImageButtonStyle(CardService.ImageButtonStyle.FILLED);

const collapseControl =
    CardService.newCollapseControl()
        .setHorizontalAlign(CardService.HorizontalAlignment.END)
        .setExpandButton(expandButton)
        .setCollapseButton(collapseButton);
```

### Methods

| Method | Return type | Brief description |
|---|---|---|
| `https://developers.google.com/apps-script/reference/card-service/collapse-control#setCollapseButton(Button)` | `https://developers.google.com/apps-script/reference/card-service/collapse-control#` | Sets the `https://developers.google.com/apps-script/reference/card-service/button` that is displayed for "show less" button. |
| `https://developers.google.com/apps-script/reference/card-service/collapse-control#setExpandButton(Button)` | `https://developers.google.com/apps-script/reference/card-service/collapse-control#` | Sets the `https://developers.google.com/apps-script/reference/card-service/button` that is displayed for "show more" button. |
| `https://developers.google.com/apps-script/reference/card-service/collapse-control#setHorizontalAlign(HorizontalAlignment)` | `https://developers.google.com/apps-script/reference/card-service/collapse-control#` | Sets the `https://developers.google.com/apps-script/reference/card-service/horizontal-alignment` of the `https://developers.google.com/apps-script/reference/card-service/collapse-control#`. |

## Detailed documentation

### `setCollapseButton(button)`

Sets the `https://developers.google.com/apps-script/reference/card-service/button` that is displayed for "show less" button. Optional.   

Must be set together with collapse button.

```javascript
const collapseButton =
    CardService.newTextButton().setText('Collapse');

const collapseControl =
    CardService.newCollapseControl()
        .setCollapseButton(collapseButton);
```

#### Parameters

| Name | Type | Description |
|---|---|---|
| `button` | `https://developers.google.com/apps-script/reference/card-service/button` | The collapse button to set. |

#### Return


`https://developers.google.com/apps-script/reference/card-service/collapse-control#` --- This object, for chaining.

*** ** * ** ***

### `setExpandButton(button)`

Sets the `https://developers.google.com/apps-script/reference/card-service/button` that is displayed for "show more" button. Optional.   

Must be set together with collapse button.

```javascript
const expandButton =
    CardService.newTextButton().setText('Expand');

const collapseControl =
    CardService.newCollapseControl()
        .setExpandButton(expandButton);
```

#### Parameters

| Name | Type | Description |
|---|---|---|
| `button` | `https://developers.google.com/apps-script/reference/card-service/button` | The expand button to set. |

#### Return


`https://developers.google.com/apps-script/reference/card-service/collapse-control#` --- This object, for chaining.

*** ** * ** ***

### `setHorizontalAlign(horizontalAlignment)`

Sets the `https://developers.google.com/apps-script/reference/card-service/horizontal-alignment` of the `https://developers.google.com/apps-script/reference/card-service/collapse-control#`. Optional. \*

```javascript
const collapseControl = CardService.newCollapseControl().setHorizontalAlign(
    CardService.HorizontalAlignment.START,
);
```

#### Parameters

| Name | Type | Description |
|---|---|---|
| `horizontalAlignment` | `https://developers.google.com/apps-script/reference/card-service/horizontal-alignment` | The horizontal alignment of the CollapseControl widget. |

#### Return


`https://developers.google.com/apps-script/reference/card-service/collapse-control#` --- This object, for chaining.