> ## Documentation Index
> Fetch the complete documentation index at: https://www.text.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# HTML attributes

> Control the Text chat widget from any element on your page without writing JavaScript.

HTML attributes are the no-code equivalent of [`LiveChatWidget.call()`](https://www.text.com/docs/api/chat-widget-js-api/methods). Use them on website builders, CMS pages, and landing pages where adding a script isn't practical.

```html theme={null}
<button type="button" data-text-action="maximize">Chat with us</button>
```

## How it works

The `data-text-action` attribute turns any element into a chat widget control. When a customer clicks the element, the chat widget runs the action named in the attribute. The element can be a button, link, image, banner, or anything else.

Pass the settings for an action as separate attributes on the same element. Attribute names aren't case-sensitive, so both `data-text-messageDraft` and `data-text-messagedraft` work.

Two details affect whether a click runs the action:

* Elements added to the page later, for example by a single-page app, work without any extra setup.
* Clicks start working once the chat widget has finished loading. Earlier clicks do nothing.

> [!WARNING]
>
> The chat widget doesn't prevent the element's default click behavior. An `<a
>     href="/contact">` element opens the chat widget and follows the link, and a
> `<button>` element inside a form also submits that form. Use `<button
>     type="button">` to avoid this.

## Actions

The `data-text-action` attribute takes one of three values: `maximize`, `minimize`, or `send_message`. Any other value does nothing and prints a console error listing the allowed actions.

### Maximize

Maximizes the chat widget.

```html theme={null}
<button type="button" data-text-action="maximize">Chat with us</button>

<button
  type="button"
  data-text-action="maximize"
  data-text-messageDraft="Hi, I have a question about shipping"
>
  Ask about shipping
</button>

<button type="button" data-text-action="maximize" data-text-startChat="true">
  Talk to an agent now
</button>
```

**Attributes**

| Attribute | Required | Description |
| - | - | - |
| `data-text-action` | Yes | The action to run. Must be `maximize`. |
| `data-text-messageDraft` | No | The message inserted into the chat input field. If a pre-chat form is enabled, the message becomes a draft that is sent once the form is submitted. |
| `data-text-startChat` | No | Whether to start a new chat as soon as the chat widget is maximized. Only the exact value `true` turns it on. It has no effect if a chat is already active or if a pre-chat form is enabled. |

### Minimize

Minimizes the chat widget. The action takes no attributes other than `data-text-action`.

```html theme={null}
<button type="button" data-text-action="minimize">Close chat</button>
```

### Send message

Sends a message on the customer's behalf and maximizes the chat widget. Use it for quick-question elements, such as FAQ entries.

If the group is offline and continuous chats are turned off, the message isn't sent.

```html theme={null}
<button
  type="button"
  data-text-action="send_message"
  data-text-messageText="Where is my order?"
>
  Track my order
</button>
```

**Attributes**

| Attribute | Required | Description |
| - | - | - |
| `data-text-action` | Yes | The action to run. Must be `send_message`. |
| `data-text-messageText` | Yes | The message sent as the customer. A click does nothing when the value is empty. |

## Clicks inside an element

The action also runs when a customer clicks an element nested inside the one that carries `data-text-action`. This lets you turn a whole banner into a trigger:

```html theme={null}
<div
  class="help-banner"
  data-text-action="maximize"
  data-text-messageDraft="I need help choosing a size"
>
  <img src="/icons/chat.svg" alt="" />
  <span>Not sure about the size? Ask us!</span>
</div>
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.