Angular 按钮库 | ng-hub-ui-buttons
面向 Angular 22 的完整按钮系统,基于 signals API——标准按钮、FAB、speed dial 与 overlay dropdown。除 ng-hub-ui-utils 外零依赖。
最后更新 2026年8月17日
概览
团队为何搜索这个库
当你需要一个统一、可主题化的按钮生态,覆盖从行内 CTA 到浮动操作 overlay 的所有交互模式,并希望它基于 Angular Signals、拥有一致的单一 API 时,请使用 ng-hub-ui-buttons。
安装
npm install ng-hub-ui-buttons跳转到
适用于
- 主要 CTA 按钮
- 浮动操作菜单
- 上下文菜单 dropdown
- 工具栏中的纯图标操作
关于 buttons
ng-hub-ui-buttons 是面向 Angular 22+ standalone 应用的零依赖按钮库。它提供 HubButtonComponent——可作为 <hub-button> 使用,也可作为原生宿主上的属性(<button hubButton>)(五种变体 × 六种颜色 × 四种尺寸)——HubFabComponent(九个固定位置)、HubSpeedDialComponent 以及 HubDropdownDirective(基于 overlay,由 ng-hub-ui-utils 的 OverlayService 驱动)。所有视觉属性都是 CSS 自定义属性,只需一份样式表覆盖即可为整个系统设置主题。
功能指南
Button Variants
Five visual styles (solid, outline, soft, ghost, link) × six semantic colours with size scale sm–xl.
示例:
Button Variants
Button Variants
<hub-button>) instead of the [hubButton] attribute.加载 / 忙碌状态
加载中的按钮会显示可替换的动画 SVG 加载图标,并完全不可交互 —— aria-busy、原生 disabled、移出 Tab 顺序,避免重复提交。
示例:
加载 / 忙碌状态
加载 / 忙碌状态
自定义颜色与变体
color 输入是开放集合:用 hub-btn-color-rules() mixin 注册任意强调色,或用 hub-btn-variant-rules() 打造全新外观。
示例:
自定义颜色与变体
自定义颜色与变体
Floating Action Button
Fixed-position circular button with nine placement presets and optional scroll-collapse behaviour.
示例:
Floating Action Button
Floating Action Button
Speed Dial
Expandable FAB that reveals a stack of action items. Closes on Escape or backdrop click.
示例:
Speed Dial
Speed Dial
Overlay Dropdown
Directive-driven dropdown that attaches a template-ref panel to any trigger element via the overlay service.
示例:
Overlay Dropdown
Overlay Dropdown
CSS Variable Theming
Every visual detail — size, radius, shadow, colour — is a --hub-btn-* or --hub-dropdown-* custom property.
示例:
CSS Variable Theming
CSS Variable Theming
核心特性
最近更改
Version 22.9.2 - 8/8/26, 12:00 AM
fixed: Documentation links now point at the canonical localized URLs. The README linked to https://hubui.dev/<path> with no locale prefix and no trailing slash, and both forms are 301-redirected, so every reader arriving from npm or GitHub landed on a redirect instead of the canonical page.
Version 22.9.1 - 7/26/26, 12:00 AM
fixed: Declared the real ng-hub-ui-utils peer range (>=22.7.0); the previous >=1.0.0 floor resolved to a utils major without resolveHubAccent.
Version 22.8.0 - 7/5/26, 12:00 AM
added: The typed color API now also accepts neutral, light and dark (the CSS already shipped), so <hub-button color="neutral"> — and fab/speed-dial/dropdown — type-check.
added: Overridable hover + a new pressed (:active) state via --hub-btn-hover-bg/-border/-color and --hub-btn-active-bg/-border/-color — retune one interaction colour with a single line; existing visuals preserved.
added: The element form <hub-button> is now keyboard-accessible: it advertises role="button", a focusable tabindex and activates on Enter/Space; the [hubButton] attribute form on a native button/anchor stays free of redundant role/tabindex.
Version 22.5.0 - 6/30/26, 12:00 AM
changed: `HubBtnComponent` renamed to `HubButtonComponent` (the old name stays as a deprecated alias).
changed: `HubButtonComponent` now has a dual selector `hub-button, [hubButton]` — usable as `<hub-button>` or as an attribute on a native host (`<button hubButton>` / `<a hubButton>`), with the loading spinner rendered in both forms.
deprecated: `HubBtnDirective` is replaced by `HubButtonComponent` (which now matches `[hubButton]`); it remains exported as a deprecated alias.
Version 22.2.0 - 6/23/26, 12:00 AM
changed: `HubBtnComponent` selector renamed from `hub-btn` to `hub-button`.
changed: `HubBtnDirective` selector renamed from `[hubBtn]` to `[hubButton]`.
fixed: `peerDependencies`: `ng-hub-ui-utils` corrected to `>=1.0.0` to match its actual published versioning scheme.
Version 22.1.0 - 6/23/26, 12:00 AM
added: Public SCSS mixin API at `ng-hub-ui-buttons/styles`: `hub-btn-variant-rules()` generic primitive and `hub-btn-color-rules()` convenience mixin for registering custom semantic colors without modifying the library.
added: `hub-fab-color()`, `hub-dropdown-panel-color()`, `hub-dropdown-item-color()` and their `*-rules` counterparts for extending FAB and dropdown colors.
added: `HubDropdownDirective`: panel closes automatically on scroll to keep alignment with the trigger.
changed: `HubSpeedDialComponent`: trigger slot renamed from `slot="trigger"` to `hubTrigger` attribute.
changed: `HubSpeedDialItemComponent` and `HubDropdownItemComponent`: `icon` input now expects a CSS class string rendered via `<i [class]="icon()">` instead of raw text.
fixed: `HubFabComponent`: uses `position: static` when nested inside `HubSpeedDialComponent` instead of `position: fixed`.
Version 22.0.0 - 6/17/26, 12:00 AM
added: `HubBtnComponent` and `HubBtnDirective` with five variants, six colours, four sizes, loading and icon-only modes.
added: `HubFabComponent` with nine-position grid, scroll-collapse and CSS logical properties for RTL.
added: `HubSpeedDialComponent` and `HubSpeedDialItemComponent` with two-way `isOpen` model and Escape close.
added: `HubDropdownDirective` with eight placements, click/hover triggers, `closeOnSelect` and backdrop close.
added: `HubDropdownPanelComponent`, `HubDropdownItemComponent`, `HubDropdownDividerComponent`, `HubDropdownHeaderComponent` helper components.
added: SCSS token system: `:where()` zero-specificity defaults + `@each` semantic colour loops for all variants.