Skip to content
Focsd homeFocsd homeFocsd
Forms

Loading overlay

Covers a form or panel with a spinner while it loads or saves, and keeps people from editing it meanwhile.

  • Tag: focsd-loading-overlay
  • Pattern: Busy, inert region + overlay with status
  • Category: Feedback

Example

Save
HTML
<focsd-loading-overlay id="save-overlay" label="Saving changes">
<form class="stack">
<focsd-text-field label="Team name" value="Platform"></focsd-text-field>
<focsd-textarea
label="Release notes"
value="Faster search and a new export option."></focsd-textarea>
<focsd-button id="save-button" variant="action">Save</focsd-button>
</form>
</focsd-loading-overlay>
<script type="module">
const overlay = document.getElementById('save-overlay');
const save = () => new Promise((done) => setTimeout(done, 1500)); // your save
// run() shows the overlay until save() finishes (or fails).
document.getElementById('save-button').addEventListener('click', () => overlay.run(save));
</script>

Usage

Import the module once, then use the tag like any HTML element. Every framework below renders the same element; see Frameworks for setup.

<script type="module">
import '@focsd-dev/components/focsd-loading-overlay.js';
</script>
<focsd-loading-overlay label="Saving changes">…</focsd-loading-overlay>

API

Attributes

AttributePropertyTypeDefault
activeactivebooleanfalse
labellabelstring—
busy-on-submitbusyOnSubmitbooleanfalse

Methods

MethodDescription
run(task)Show the overlay while task runs: a function (called) or a promise. Resolves with its result; the overlay goes away when it settles, also on failure.

Slots

SlotDescription
(default)The content to cover.
indicatorReplaces the spinner: an image, an animation or a progress bar.
labelReplaces the text under the indicator; plain text is also announced. Or set label.

CSS parts

Style the inside of the component with ::part(), for example focsd-loading-overlay::part(region).

PartDescription
regionThe wrapper around the content; `inert` and `aria-busy` while active.
overlayThe cover shown while active; it takes focus from the content.
spinnerThe spinner in the overlay.
textThe visible text in the overlay (`label`, or "Loading").
statusThe visually hidden status region that announces loading and loaded.

Accessibility

  • While active, the content is inert (no focus, no clicks, hidden from assistive technology) and marked aria-busy.
  • "Loading" (or label) is announced when loading starts and "Loaded" when it ends, through a polite status region. When focus moves to the overlay, its name already says "Loading", so the status stays quiet until "Loaded".
  • An overlay that is already active when it first renders neither announces nor moves focus; only later changes of active do.
  • If focus was inside the content, it moves to the overlay while loading and comes back afterwards; if that element is gone, it goes to the first focusable element in the content. Focus elsewhere on the page is left alone.
  • Use label to say what is happening ("Saving changes"); keep it short. For richer content, put an element with slot="label" inside (its text is announced), and slot="indicator" for your own image or animation in place of the spinner.
  • No glue code for the common cases: run(save) shows it until save() settles, and busy-on-submit turns it on when a form inside posts to the server.
  • In forced colors the overlay is an opaque system surface with an outline.