Angular Toast 通知服务 | ng-hub-ui-toast
standalone 的 Angular toast 通知服务,支持 Signals、生命周期 observables、进度条、六个位置以及完整的 CSS 变量主题化。
样式
混入与样式
Override any of the `--hub-toast-*` design tokens in a single include. Every parameter is OPTIONAL and defaults to `null`: only the parameters you pass are emitted, so the rest keep the component's defaults. Token-based and self-contained (no Bootstrap dependencies).
Theming with hub-toast-theme
| 混入 | 参数 | 描述 |
|---|---|---|
| Theming | ||
hub-toast-theme() | $accent--hub-toast-accent$bg--hub-toast-bg$color--hub-toast-color$border--hub-toast-border$border-width--hub-toast-border-width$border-radius--hub-toast-border-radius$shadow--hub-toast-shadow$min-width--hub-toast-min-width$max-width--hub-toast-max-width$padding-x--hub-toast-padding-x$padding-y--hub-toast-padding-y$gap--hub-toast-gap$font-size--hub-toast-font-size$title-font-size--hub-toast-title-font-size$title-font-weight--hub-toast-title-font-weight$progress-bg--hub-toast-progress-bg$progress-height--hub-toast-progress-height$close-opacity--hub-toast-close-opacity$close-opacity-hover--hub-toast-close-opacity-hover$container-gap--hub-toast-container-gap$container-offset--hub-toast-container-offset$container-z-index--hub-toast-container-zindex | One-call theming for `<hub-toast>` notifications |
CSS 变量
用 22 个 CSS 变量为每一个像素设置主题。在 :root 处覆盖它们,或将其限定到某个容器范围内。
Toast
Design tokens read by this component. Override them on the host element (or any ancestor) to customize; every default falls back to the ng-hub-ui-ds layer.
| 变量 | 默认值 | 类型 | 描述 |
|---|---|---|---|
--hub-toast-accent | var(--hub-sys-border-color-default, #dee2e6) | color | 左边框或高亮颜色;对于内置类型会自动从 DS 令牌族中设置。 |
--hub-toast-bg | var(--hub-sys-surface-page, #fff) | color | toast 卡片的背景颜色。 |
--hub-toast-border | var(--hub-sys-border-color-default, #dee2e6) | border | Toast border color (per type → the accent) |
--hub-toast-border-radius | var(--hub-ref-radius-md, 0.375rem) | length | toast 卡片的圆角半径。 |
--hub-toast-border-width | var(--hub-ref-border-width, 1px) | length | Toast border width |
--hub-toast-close-opacity | 0.5 | number | Close button opacity |
--hub-toast-close-opacity-hover | 1 | number | Close button hover opacity |
--hub-toast-color | var(--hub-sys-text-primary, #212529) | color | toast 主体文本颜色。 |
--hub-toast-container-gap | var(--hub-ref-space-2, 0.5rem) | length | 容器中相邻 toast 之间的垂直间距。 |
--hub-toast-container-offset | var(--hub-ref-space-3, 1rem) | length | 从屏幕边缘到容器的距离。 |
--hub-toast-container-zindex | var(--hub-sys-zindex-toast, 1090) | number | toast 容器相对于其他 overlay 的堆叠顺序。 |
--hub-toast-font-size | var(--hub-ref-font-size-base, 1rem) | length | Toast font size |
--hub-toast-gap | var(--hub-ref-space-1, 0.25rem) | length | 容器中堆叠 toast 之间的间距。 |
--hub-toast-max-width | 26rem | length | 每个 toast 卡片的最大宽度。 |
--hub-toast-min-width | 18rem | length | Toast minimum width |
--hub-toast-padding-x | var(--hub-ref-space-3, 1rem) | length | toast 主体内部的水平内边距。 |
--hub-toast-padding-y | var(--hub-ref-space-3, 1rem) | length | toast 主体内部的垂直内边距。 |
--hub-toast-progress-bg | color-mix(in oklch, var(--hub-toast-accent) 30%, transparent) | color | 进度条填充的背景颜色。 |
--hub-toast-progress-height | 0.25rem | length | 进度条条带的高度。 |
--hub-toast-shadow | var(--hub-sys-shadow-md, 0 0.5rem 1rem rgba(0, 0, 0, 0.15)) | shadow | toast 卡片投射的阴影。 |
--hub-toast-title-font-size | var(--hub-ref-font-size-base, 1rem) | length | Toast 标题的字体大小。 |
--hub-toast-title-font-weight | var(--hub-ref-font-weight-semibold, 600) | number | Toast 标题的字体粗细。 |