ReviewOS

stacks/stx

Built-in Loading Overlay (<StxLoading />)

#1676
Closed glennmichael123 opened this 23 days ago · 1 comment
23 days ago

Summary

Add a full-page or container-scoped loading overlay with spinner — for route transitions, data fetching, and async operations.

Usage

<!-- Full page loading (place in layout) -->
<StxLoading />

<!-- Trigger programmatically -->
<script client>
  loading.show('Fetching data...')
  const data = await fetch('/api/items').then(r => r.json())
  loading.hide()
</script>

<!-- Container-scoped -->
<div style="position:relative">
  <StxLoading target="container" id="table-loading" />
  <table>...</table>
</div>

API

<StxLoading> props

  • id — identifier for targeted show/hide (default: 'default')
  • target — 'page' (fixed fullscreen) | 'container' (absolute within parent) (default: 'page')
  • spinner — 'dots' | 'ring' | 'bars' (default: 'ring')
  • text — default loading text

loading runtime global

loading.show(text?: string, id?: string): void
loading.hide(id?: string): void
loading.isVisible(id?: string): boolean

Implementation

  • Builtin component rendering a hidden overlay with CSS spinner
  • Runtime show/hide with fade animation
  • Page-level locks scroll, container-level is positioned absolute
  • Works with SPA navigation (auto-show on route change, hide on load)
  • Dark mode support
  • Accessible: role="progressbar", aria-busy
23 days ago

Delivered via @stacksjs/components, which ships with every stx app and is auto-registered (no import needed in .stx files). See CLAUDE.md § "Reach for stx primitives before vanilla JS" for the full inventory; the relevant components for this request are documented there.

Closing as effectively delivered. If a specific behavior or API affordance from the original request is missing from the shipped components, please open a focused ticket against @stacksjs/components describing the exact gap — that's easier to track than a broad "make it a builtin" ask.

Sign in to comment on this issue.