| 1 | --- |
| 2 | title: "htmx.config" |
| 3 | description: "Configure htmx behavior globally" |
| 4 | --- |
| 5 | |
| 6 | The `htmx.config` object holds the current htmx configuration. You can modify it in JavaScript or set values using a `<meta>` tag. |
| 7 | |
| 8 | ## Configuration via Meta Tag |
| 9 | |
| 10 | Set config values in your HTML `<head>`: |
| 11 | |
| 12 | ```html |
| 13 | <meta name="htmx-config" content='{"defaultSwap":"outerHTML","defaultTimeout":5000}'> |
| 14 | ``` |
| 15 | |
| 16 | ## Configuration via JavaScript |
| 17 | |
| 18 | Modify config values directly: |
| 19 | |
| 20 | ```javascript |
| 21 | htmx.config.defaultSwap = 'outerHTML'; |
| 22 | htmx.config.defaultTimeout = 5000; |
| 23 | ``` |
| 24 | |
| 25 | ## Available Options |
| 26 | |
| 27 | - `version` - htmx version (read-only) |
| 28 | - `logAll` - Log all htmx events (default: `false`) |
| 29 | - `prefix` - Secondary attribute prefix recognised alongside `hx-` (default: `"data-hx-"`) |
| 30 | - `transitions` - Enable view transitions (default: `false`) |
| 31 | - `history` - Enable history support (default: `true`) |
| 32 | - `mode` - Request mode for fetch (default: `"same-origin"`) |
| 33 | - `defaultSwap` - Default swap style (default: `"innerHTML"`) |
| 34 | - `indicatorClass` - CSS class for indicators (default: `"htmx-indicator"`) |
| 35 | - `requestClass` - CSS class during requests (default: `"htmx-request"`) |
| 36 | - `includeIndicatorCSS` - Include default indicator CSS (default: `true`) |
| 37 | - `defaultTimeout` - Request timeout in ms (default: `60000`) |
| 38 | - `extensions` - Extensions to load (default: `""`) |
| 39 | - `morphIgnore` - Attributes to ignore during morphing (default: `["data-htmx-powered"]`) |
| 40 | - `morphSkip` - CSS selector for elements to skip morphing entirely (default: `'[hx-morph-skip]'`) |
| 41 | - `morphSkipChildren` - CSS selector for elements whose children won't be morphed (default: `'[hx-morph-skip-children]'`) |
| 42 | - `noSwap` - HTTP status codes that skip swap (default: `[204, 304]`) |
| 43 | - `implicitInheritance` - Enable implicit attribute inheritance (default: `false`) |