# Javascript: ParagraphStyleCollection.add Method

> Adds a new style to the current document.

- **Product:** DS Server
- **Section:** Reference
- **Kind:** Method
- **Introduced:** 28.0
- **Path:** DS Server > Reference > JavaScript API > Javascript: ParagraphStyleCollection.add Method
- **388 words**
- **Web URL:** https://docs.textcontrol.com/ds-server/reference/javascript/paragraphstylecollection/add-method/
- **LLMs URL:** https://docs.textcontrol.com/ds-server/reference/javascript/paragraphstylecollection/add-method/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/ds-server/reference/javascript/paragraphstylecollection/add-method/llms-full.txt

---

### Description

Adds a new style to the current document.

### Syntax

```javascript
<void> ParagraphStyleCollection.add(<String> styleName, [<RequestParagraphStyleCallback> callback], [<ErrorCallback> errorCallback])
```

### Parameters

| Parameter | Description |
|---|---|
| styleName | Specifies the style's name. |
| callback | Optional. Receives the added style if the style is succesfully added. Otherwise null. |
| errorCallback | Optional. Is called when the operation failed with an error. |

### Examples

The following example demonstrates `ParagraphStyleCollection.add` in a practical document-editing workflow. It adds a new style to the current document.

```javascript
function onTxError(error) {
    console.error("TX Text Control error:", error.msg);
    error.handled = true;
}

TXTextControl.paragraphStyles.add(
    "Heading 1",
    function(style) {
        if (!style) {
            console.warn("No paragraph style was returned.");
            return;
        }
        
        console.log("add result:", style);
    },
    onTxError
);
```

---

## Nearby

- **Previous:** [ParagraphStyleCollection Object](https://docs.textcontrol.com/ds-server/reference/javascript/paragraphstylecollection/llms-full.txt)
- **Next:** [Javascript: ParagraphStyleCollection.getItem Method](https://docs.textcontrol.com/ds-server/reference/javascript/paragraphstylecollection/getitem-method/llms-full.txt)
