--- includeMockServer: true title: "Progress Bar" description: Show progress bar during background job icon: "icon-[vaadin--progressbar]" ---
## Basic usage On the client, a button starts the job. ```html ``` On the server, respond with a container that polls for progress: ```html
...progress bar...
``` - [`hx-trigger`](/reference/attributes/hx-trigger)=[`"every 400ms"`](/reference/attributes/hx-trigger#polling) polls the server on an interval. - [`outerMorph`](/reference/attributes/hx-swap#outermorph) morphs the element in place, so CSS transitions on `transform` animate smoothly. Each poll returns updated progress. When done, the server responds with [HTTP 286](https://en.wikipedia.org/wiki/86_(term)) to stop polling. ## Notes ### Use `transform` instead of `width` Animating `width` causes [layout recalculation](https://web.dev/articles/avoid-large-complex-layouts-and-layout-thrashing). Use `transform: scaleX()` instead ([GPU-composited](https://web.dev/articles/stick-to-compositor-only-properties-and-manage-layer-count), no layout thrashing): ```css .bar { width: 100%; transform: scaleX(0); transform-origin: left; transition: transform 400ms ease-in-out; } ``` The server returns `style="transform: scaleX(0.65)"` instead of `style="width: 65%"`. Same look, no layout thrashing. The demo above uses this approach.