Debian Codegraph @

www/src/content/extensions/11-hx-browser-indicator.md

raw symbols SCIP
1 ---
2 title: "hx-browser-indicator"
3 description: "Show the browser's native loading indicator"
4 category: "UX"
5 icon: "icon-[mdi--tab-search]"
6 keywords: ["browser", "indicator", "loading", "spinner", "tab"]
7 ---
8
9 The `browser-indicator` extension shows the browser's native loading indicator (the tab spinner) during htmx requests. This gives users the same visual feedback they get during full-page navigations, without any custom CSS or HTML.
10
11 This extension requires the [Navigation API](https://developer.mozilla.org/en-US/docs/Web/API/Navigation_API), which is available in Chromium-based browsers. In browsers that don't support it, the extension is a no-op.
12
13 ## Installing
14
15 ```html
16 <script src="https://cdn.jsdelivr.net/npm/htmx.org@__VERSION__/dist/htmx.min.js"></script>
17 <script src="https://cdn.jsdelivr.net/npm/htmx.org@__VERSION__/dist/ext/hx-browser-indicator.js"></script>
18 ```
19
20 ## Usage
21
22 Add `hx-browser-indicator="true"` to elements whose requests should show the browser indicator:
23
24 ```html
25 <button hx-get="/api/data" hx-browser-indicator="true">
26 Load Data
27 </button>
28 ```
29
30 While the request is in flight, the browser's tab spinner will be active just like a normal page load.
31
32 ### Boosted Elements
33
34 Instead of marking individual elements, you can enable the indicator for all boosted links and forms via config:
35
36 ```html
37 <meta name="htmx-config" content='{"extensions": "browser-indicator", "boostBrowserIndicator": true}'>
38 ```
39
40 With this config, any element with [`hx-boost`](/reference/attributes/hx-boost) will automatically show the browser indicator during its requests.
41
42 ### Browser Stop Button
43
44 If the user clicks the browser's stop button while a request is in flight, the extension will abort all active htmx requests that are showing the indicator.
45
46 ## Notes
47
48 - Requires the [Navigation API](https://developer.mozilla.org/en-US/docs/Web/API/Navigation_API) (Chromium 105+). The extension does nothing in browsers that don't support it.
49 - As of this writing, Firefox supports the Navigation API but does not properly show a spinner.
50 - Multiple concurrent requests are handled: the indicator stays active until all tracked requests complete.