TextParagraph

A widget that displays text and supports [basic HTML formatting](https://developers.google.com/gmail/add-ons/concepts/widgets#text_formatting).

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

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

### Methods

| Method | Return type | Brief description |
|---|---|---|
| `https://developers.google.com/apps-script/reference/card-service/text-paragraph#addEventAction(EventAction)` | `https://developers.google.com/apps-script/reference/card-service/widget` | Adds the event action that can be performed on the widget. |
| `https://developers.google.com/apps-script/reference/card-service/text-paragraph#setId(String)` | `https://developers.google.com/apps-script/reference/card-service/widget` | Sets the unique ID assigned that's used to identify the widget to be mutated. |
| `https://developers.google.com/apps-script/reference/card-service/text-paragraph#setMaxLines(Integer)` | `https://developers.google.com/apps-script/reference/card-service/text-paragraph#` | Sets the maximum number of lines of text that are displayed in the widget. |
| `https://developers.google.com/apps-script/reference/card-service/text-paragraph#setText(String)` | `https://developers.google.com/apps-script/reference/card-service/text-paragraph#` | Sets the text of the paragraph. |
| `https://developers.google.com/apps-script/reference/card-service/text-paragraph#setVisibility(Visibility)` | `https://developers.google.com/apps-script/reference/card-service/widget` | Sets the visibility of the widget. |

## Detailed documentation

### `addEventAction(eventAction)`

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

#### Parameters

| Name | Type | Description |
|---|---|---|
| `eventAction` | `https://developers.google.com/apps-script/reference/card-service/event-action` | The `https://developers.google.com/apps-script/reference/card-service/event-action` to be added. |

#### Return


`https://developers.google.com/apps-script/reference/card-service/widget` --- The Object, for chaining.

*** ** * ** ***

### `setId(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


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

*** ** * ** ***

### `setMaxLines(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.


> [!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 textParagraph =
    CardService.newTextParagraph()
        .setText(
            'This is a text paragraph widget. Multiple lines are allowed if needed.',
            )
        .setMaxLines(1);
```

#### Parameters

| Name | Type | Description |
|---|---|---|
| `maxLines` | `Integer` | The maximum number of lines of text that are displayed. |

#### Return


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

*** ** * ** ***

### `setText(text)`

Sets the text of the paragraph. Required.

#### Parameters

| Name | Type | Description |
|---|---|---|
| `text` | `String` | The text to display. |

#### Return


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

*** ** * ** ***

### `setVisibility(visibility)`

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

#### Parameters

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

#### Return


`https://developers.google.com/apps-script/reference/card-service/widget` --- The Object, for chaining.