LoadingBar
A global loading progress bar at the top (or bottom) of the page, driven by an imperative API. Multiple start calls count concurrent sessions — only the last finish/error closes the bar. Supports incremental control, local containers, reverse/RTL, and lifecycle events.
Basic usage
Start & finish
Active sessions: false
loadingBar.start() auto-advances the progress (asymptotically approaching 90%); finish() fills the bar and fades it out.
Error state
Error & fallback
Calling error() without a prior start is a fallback scenario: it skips the loading phase and closes directly in the error state (red + fade-out), so failures stay visible without flicker. Any error() in a batch decides the final state.
Session counting
Concurrent sessions
Active sessions: 0
Multiple start calls are counted; the bar advances once. Each completed session calls finish() once — only the last one closes the bar. The active count is displayed live (query it with loadingBar.getEl()?.sessions).
Position
Top / bottom
Local container
Local loading bar
to mounts the bar into a specific container (element / selector / function); it is positioned relative to that container and does not affect the global bar. The container must be a positioning context (e.g. position: relative), otherwise position: absolute resolves against the nearest positioned ancestor.
Incremental control
Incremental control & speed
Current progress: —
increment/decrement move the progress relatively (default random 0–10); set positions it exactly (clamped to 0–100). start(speed) or the speed attribute control the advance tick (ms per tick).
Reverse & RTL
Reverse / RTL
reverse grows the bar from the inline end; in RTL it grows from the inline start (right side) by default. Layout uses logical properties (inset-inline-* / inset-block-*) throughout.
Lifecycle events
Events & active state
Latest event: —
Lifecycle events fire on the bar element (oas-start / oas-finish / oas-error, bubbles + composed, reachable from document). Query the active state with loadingBar.active / isActive(), or grab the element with getEl() to attach listeners.
Clear
Clear
API
oas-loading-bar
Attributes
| Attribute | Description | Type | Default |
|---|---|---|---|
local | Local-mode marker (boolean): set automatically when the imperative API is given a to container; the component switches to absolute positioning inside that container. Does not accept a selector/element — the mount target is decided by the imperative to option | — | — |
position | Position: top (default) / bottom | — | — |
reverse | Reverse direction (RTL progress flows right to left) | — | — |
speed | Base advance speed (ms, default 200); start(speed) overrides | string | 200 |
status | Current status (activity query): the component only writes error at the error terminal state and removes the attribute otherwise (never writes loading/finish) | string | — |
Methods
| Method | Signature | Description |
|---|---|---|
start | start(speed?: number): void | Start a loading session: increments the concurrency count; the first session starts progress and dispatches oas-start |
finish | finish(): void | Complete a session: decrements the concurrency count; only the last finish triggers the wrap-up |
error | error(): void | Failure wrap-up: decrements the concurrency count; any error in the batch decides the final state |
increment | increment(step?: number): void | Advance progress by step manually (random 0–10 by default); clamped to 0–100 |
set | set(percent: number): void | Set progress precisely (clamped to 0–100) |
decrement | decrement(step?: number): void | Roll progress back by step manually (random 0–10 by default); clamped to 0–100 |
Events
| Event | Description |
|---|---|
oas-error | Dispatched when error() finalizes in the error state, detail: { count: this.sessionCount } |
oas-finish | Dispatched when finish() finalizes, detail: { count: this.sessionCount } |
oas-start | Dispatched when the first session of a batch calls start() (subsequent start() calls of a concurrent batch do not re-dispatch), detail: { count: this.sessionCount } |
CSS Variables
| CSS Variable | Default |
|---|---|
--oas-loading-bar-color | var(--oas-color-primary) |
--oas-loading-bar-error-color | var(--oas-color-danger) |
--oas-loading-bar-height | 3px |
--oas-loading-bar-z-index | calc(var(--oas-z-index-base, 0) + var(--oas-z-message, 1060)) |
target is a container element / CSS selector / function returning an element; it defaults to the nearest oas-app host or body.
The bar uses role="progressbar" with progress synced via aria-valuenow and the active state via aria-busy.