Angular 加载指示器与遮罩层 | ng-hub-ui-loading
Angular 加载组件,提供 spinner、dots、bars、pulse、ring 五种指示器,支持 inline、overlay 与 fullscreen 三种模式,并附带用于全应用阻塞遮罩的服务。
交互式示例
探索实时示例,了解该库在常见 Angular 用例中的表现。
内联块
`inline` 之所以是默认模式,是因为一块尚且为空的区域本就该先把内容将要占据的空间留出来:该块参与正常的文档流,因此真实内容到达时不会发生跳动。`message` 渲染在指示器下方,标签之间投影的任何内容再渲染在消息下方——那是放置取消操作,或提示“本次操作比平时更久”的位置。宿主元素带有 `role="status"`、`aria-live="polite"` 与 `aria-busy="true"`,因此屏幕阅读器会在消息出现时读到它,而不会打断正在朗读的内容。
内联块基础
The block is announced as role="status" with aria-live="polite", so a screen reader reads the message when it appears without interrupting whatever is being read.
指示器与强调色
库内置五种纯 CSS 指示器——`spinner`、`dots`、`bars`、`pulse` 与 `ring`——因此不会引入任何图片资源或图标字体。三档尺寸预设了 `--hub-loading-size`,而当布局需要这三档之外的尺寸时,该令牌本身仍可单独覆盖。`color` 并非普通的 CSS 颜色:它会经过 `resolveHubAccent()`,把 `primary` 这样的裸名称解析为跟随主题的设计系统令牌,而 hex、`oklch()` 字面量或 `var(...)` 引用则原样使用。
变体、尺寸与强调色
Variants
spinnerdotsbarspulseringSizes
size="sm"size="md"size="lg" Each step is a preset for the --hub-loading-size token. Override that token directly when a layout needs a size the three steps do not cover.
Accents
color="primary"color="success"color="danger"color="#7c3aed"color="var(--hub-sys-color-warning)" A bare name resolves to var(--hub-sys-color-<name>) and tracks the active theme. A hex, an oklch() or a var(...) is used verbatim.
Overlay 与全屏
`overlay` 覆盖的是某一块区域,而不是整个页面。它采用绝对定位,因此由最近的已定位祖先决定被覆盖的范围——请给该容器加上 `position: relative`,否则 overlay 会一路向上逃逸到碰巧被定位的那个祖先。这样限定范围可以让页面其余部分仍能滚动与操作。`fullscreen` 固定于 viewport,正是 `HubLoadingService` 挂载到 `document.body` 上的那一层;它位于所有组件子树之外,因此不会被祖先的 `overflow` 或层叠上下文裁切。除非关闭 `backdrop`,两种模式都会绘制半透明遮罩。
容器 overlay
Order #4821
3 items · delivered 14 Aug 2026
- Subtotal
- 212.00 €
- Shipping
- 9.90 €
- VAT (21%)
- 26.70 €
- Total
- 248.60 €
Turn the backdrop off to keep the content readable underneath — useful when the work is a background refresh rather than something that invalidates what is on screen.
全屏服务
hideAll() after 5 seconds no matter what. Nothing yet.
品牌化与主题化
`image` 会用你自己的标识替换内置指示器,并以 `none`、`spin` 或 `pulse` 赋予动效:`spin` 只在径向对称的标识上才好看,而 `pulse` 能让文字标识保持端正易读。所有视觉相关的设定都在 `--hub-loading-*` 令牌里,声明于 `:where(.hub-loading)`,因此任何祖先都能设置它们——强调色、尺寸、速度、线条粗细、间距、图像尺寸、文本颜色,以及遮罩的色调与模糊。Sass 混入 `hub-loading-theme()` 一次调用即可设定整套令牌,而 `provideHubLoading()` 无需改动任何模板就能为整个应用重设默认值。
品牌图像
imageAnimation="none"imageAnimation="spin"imageAnimation="pulse" Any URL works — an asset path, an imported file or, as here, an inline data URI. Size the mark with --hub-loading-image-size rather than size, which drives the built-in indicators.
CSS 变量主题化
Overlay preview
The backdrop tint and blur only apply in overlay and fullscreen modes. The tint is mixed from --hub-sys-surface-page, so it veils this text with the theme's own surface instead of a fixed colour — drop it to zero and the card stays fully legible underneath.
The same overrides written once, in Sass, are in the CSS tab — that is what hub-loading-theme() is for.