---
title: "toggleWrap command"
description: "Use the toggleWrap command in Tiptap to wrap the current node with a new node or remove a wrapping node. Learn more in our docs!"
canonical_url: "https://tiptap.dev/docs/editor/api/commands/nodes-and-marks/toggle-wrap"
---

# toggleWrap command

Use the toggleWrap command in Tiptap to wrap the current node with a new node or remove a wrapping node. Learn more in our docs!

`toggleWrap` wraps the current node with a new node or removes a wrapping node.

## Parameters

`typeOrName: string | NodeType`

The type of node that should be used for the wrapping node.

`attributes?: Record<string, any>`

The attributes that should be applied to the node. **This is optional.**

## Use the toggleWrap command

```js
// toggle wrap the current selection with a heading node
editor.commands.toggleWrap('heading', { level: 1 })
```
