# Replace clauses from your application

> Replace a tagged block-level field from application-owned UI.



Use a block-level content control as a clause slot. The DOCX owns where the clause appears. Your application owns the
available clauses and chooses which content fills that slot.

## Try a clause slot [#try-a-clause-slot]

Choose a clause below. The Editor replaces the paragraph inside the control tagged `agreement.confidentiality`.

> **Interactive editor: Choose a confidentiality clause**
>
> The DOCX contains one block-level content control tagged `agreement.confidentiality`.
>
> - **Mutual:** Each party must protect the other party's confidential information and use it only to perform this agreement.
> - **Recipient only:** The receiving party must protect the disclosing party's confidential information and use it only to perform this agreement.
> - **Limited use:** The recipient may use confidential information only to evaluate and perform the services described in this agreement.
>
> Choosing an option replaces the paragraph inside the control. Reset restores the original clause.


## Replace the clause [#replace-the-clause]

Find the slot by tag, require one block-level control, then replace its content:

```ts
import type { BrowserDocumentApi } from 'superdoc/ui';

export async function replaceClause(doc: BrowserDocumentApi, tag: string, content: string) {
  const { items } = await doc.contentControls.selectByTag({ tag });

  if (items.length !== 1) {
    throw new Error(`Expected one content control tagged "${tag}", found ${items.length}.`);
  }

  const [control] = items;
  if (control.kind !== 'block') {
    throw new Error(`Content control "${tag}" must be block-level.`);
  }

  return doc.contentControls.replaceContent({
    target: control.target,
    content,
    format: 'text',
  });
}

```

`replaceContent()` changes the content inside the control. Its tag and ID remain attached to the slot. Inspect the
mutation receipt before updating your application UI.

In the current Editor, replacement content is rebuilt as text. Keep each replaceable clause to one paragraph. Your
application can store approval state, versions, and clause metadata outside the DOCX.

Continue with [Lock template fields](/editor/content-controls/lock-template-fields) to keep a clause slot or its contents
from being removed. Use the [Document API reference](/document-api/reference/content-controls/) for every
content-control operation.
