| 1 | --- |
| 2 | title: "htmx.config.morphSkipChildren" |
| 3 | description: "Skip morphing children of specific elements" |
| 4 | --- |
| 5 | |
| 6 | The `htmx.config.morphSkipChildren` option is a CSS selector for elements whose children won't be morphed. |
| 7 | |
| 8 | The element itself updates (attributes change). Its children stay untouched. |
| 9 | |
| 10 | **Default:** `'[hx-morph-skip-children]'` |
| 11 | |
| 12 | Add `hx-morph-skip-children` to any element in your server templates to freeze its children during morph while still allowing its own attributes to update: |
| 13 | |
| 14 | ```html |
| 15 | <lit-component hx-morph-skip-children value="{{value}}">...</lit-component> |
| 16 | ``` |
| 17 | |
| 18 | Or override with any CSS selector: |
| 19 | |
| 20 | ```javascript |
| 21 | htmx.config.morphSkipChildren = "my-component"; |
| 22 | ``` |
| 23 | |
| 24 | ## Use Cases |
| 25 | |
| 26 | **Custom web components:** |
| 27 | Update component attributes but preserve managed children. |
| 28 | |
| 29 | **Client-managed DOM:** |
| 30 | Let JavaScript frameworks control their own DOM trees. |
| 31 | |
| 32 | **Multiple components:** |
| 33 | ```javascript |
| 34 | htmx.config.morphSkipChildren = "my-component, other-component, .skip-kids"; |
| 35 | ``` |
| 36 | |
| 37 | ## Difference from morphSkip |
| 38 | |
| 39 | - **`morphSkip`:** Freezes entire element (no changes at all) |
| 40 | - **`morphSkipChildren`:** Updates element attributes, freezes children only |