| 1 | --- |
| 2 | title: "htmx:before:settle" |
| 3 | description: "Before the settle phase begins after a swap" |
| 4 | --- |
| 5 | |
| 6 | The `htmx:before:settle` event fires after new content is inserted into the DOM but before CSS transitions are applied. |
| 7 | |
| 8 | ## When It Fires |
| 9 | |
| 10 | After the swap completes, right before htmx runs the settle phase (which applies CSS transitions and removes old attributes). |
| 11 | |
| 12 | ## Event Detail |
| 13 | |
| 14 | - `task` - The swap task being settled |
| 15 | - `newContent` - Array of newly inserted elements |
| 16 | - `settleTasks` - Array of pending settle callbacks (e.g. CSS transition steps) |
| 17 | |
| 18 | ## Example |
| 19 | |
| 20 | ```javascript |
| 21 | htmx.on('htmx:before:settle', (evt) => { |
| 22 | console.log('About to settle', evt.detail.newContent.length, 'element(s)'); |
| 23 | // Modify elements before transitions run |
| 24 | }); |
| 25 | ``` |