@gemeente-denhaag/button

中文文档
3.2.0发布于 2026/10/05EUPL-1.2TypeScriptESM + CJS构建来源已验证近 30 天下载 2.5万

A Button component

原始使用文档
文档目录18 节
  1. When to use
  2. Alternatives and related components
  3. Anatomy
  4. (Interactive) states
  5. Design properties
  6. Typography
  7. Colors
  8. Interactive states
  9. Structure
  10. Accessibility
  11. Navigation
  12. Keyboard support
  13. Content guidelines
  14. Best practices
  15. Do's
  16. Don'ts
  17. Buttons versus links
  18. References

Button

npm version GitHub Workflow Status (branch)

Buttons are used for actions such as "Add", "Close", "Cancel" or "Save". Button labels indicate what action will take place when the user interacts with it.

When to use

Use buttons to communicate actions users can take and to allow users to interact with the page. Each page should have one primary button, and any remaining calls to action should be represented as lower emphasis buttons.

Use Link for navigation actions that appear within or immediately after a sentence.

Navigate to Link

Anatomy

The button consists of:

  1. Label: communicates the action that will be performed when the user interacts with it.
  2. Icon (optional): provides support for the label.
  3. Container

(Interactive) states

The button contains the states normal, hover, disabled and focus.

Design properties

Typography

Large

  • Label: TheSans/lg/400

Medium

  • Label: TheSans/md/400

Colors

Primary button

  • Label: text color white
  • Icon: svg color white
  • Container: background-color Green/3

Secondary button

  • Label: text color Green/3
  • Icon: svg color Green/3
  • Container: background-color white, border Green/3

Interactive states

Primary button

  • Hover: container background-color Green/4
  • Disabled: container background-color Grey/2
  • Focus: container border color Ocher/5

Secondary button

  • Hover: label text color Green/4, icon svg color Green/4, container border color Green/4
  • Disabled: label text color Grey/2, icon svg color Grey/2, container border color Grey/2
  • Focus: container border color Ocher/5

Structure

Large

  • Label: padding-left and padding-right 20px
  • Icon: height and width 24px
  • Icon-left: padding-left 16px, padding-right 8px
  • Icon-right: padding-left 8px, padding-right 16px
  • Container: height 48px

Medium

  • Label: padding-left and padding-right 16px
  • Icon: height and width 20px
  • Icon-left: padding-left 12px, padding-right 8px
  • Icon-right: padding-left 8px, padding-right 12px
  • Container: height 40px

Primary button

  • Container focus: container border 2px, dash 5,5

Secondary button

  • Container: border 1px
  • Container focus: container border 2px, dash 5,5

Accessibility

Alert provide context and assist workflows for users with disabilities.

  • Alert use a combination of icons and colors to show their meaning and importance.
  • [technical accessibility requirements]

Navigation

Users generally expect buttons to send data or take action, and to be able to navigate links. If navigation is required for the button component, use the url prop. The control displays an anchor in the form of a button, instead of a button in HTML, to convey this difference.

See links for more information on creating accessible links.

Keyboard support

Buttons use the browser's default settings for keyboard interactions.

  • Give buttons keyboard focus with the tab key (or shift + tab when tabbing backwards)
  • Activate buttons with the enter / return key or the space key

Content guidelines

Buttons should be clear and predictable. Users should be able to anticipate what will happen when they select a button. Never mislead anyone by mislabeling a button.

Buttons should always lead with a strong verb that encourages action. To provide users with enough context, you can use the content formula {verb} + {noun} on buttons, except in the case of general actions such as "Done", "Close", "Cancel" or "OK".

Best practices

Do's

Buttons must:

  • Be clearly and accurately labeled.
  • Contain a strong and action-oriented verb.
  • Using the right button colors in the right context. For example, only use a red error button for an action that is difficult or impossible to undo.
  • Give priority to the most important actions. Too many calls to action can cause confusion and make users unsure of what to do next.
  • Be positioned in consistent locations in the interface.

Don'ts

Buttons must:

  • Do not guess the user what a button does, especially if it is irreversible.
  • Not be used for navigation. You can use links for this.
  • Not wrapped on more than 1 line. Make sure the text stays on one line.

Buttons are mainly used for actions such as "Add", "Close", "Cancel" or "Save". Regular buttons similar to links are used for less important or less frequently used actions, such as "View details".

Links are mainly used for navigation and usually appear in or immediately after a sentence.

The HTML displayed for the Button and Link components has meaning. Using these components intentionally and consistently results in:

  • a more inclusive experience for assistive technology users
  • a more coherent visual experience for sighted users
  • products that are easier to maintain to scale

References

https://uxmovement.com/buttons/5-rules-for-choosing-the-right-words-on-button-labels/
https://uxplanet.org/7-basic-rules-for-button-design-63dcdf5676b4
https://www.invisionapp.com/inside-design/comprehensive-guide-designing-ux-buttons/

版本与发布记录

@gemeente-denhaag/button 共发布 440 个版本,首次发布于 2021/03/20;过去 12 个月发布了 8 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
3.2.0latest2026/10/051 个月前
3.1.32026/09/231 个月前
3.1.22026/08/272 个月前
3.1.12026/07/273 个月前
3.1.02026/06/294 个月前
3.0.42026/06/115 个月前

关于 @gemeente-denhaag/button 的常见问题

@gemeente-denhaag/button 是什么?

A Button component

如何安装 @gemeente-denhaag/button?

在项目目录运行 npm install @gemeente-denhaag/button,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(18 || 19)、react-dom(18 || 19)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@gemeente-denhaag/button 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@gemeente-denhaag/button 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@gemeente-denhaag/button 可以商用吗?

@gemeente-denhaag/button 使用 EUPL-1.2 许可。声明的许可为 EUPL-1.2,请阅读许可原文确认使用条件。以上为概括,不构成法律意见,请以许可原文为准。

@gemeente-denhaag/button 的下载量有多少?

根据 npm 官方下载统计,@gemeente-denhaag/button 在 2026/10/16 – 2026/11/14 这 30 天内被下载 24,836 次,日均约 828 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@gemeente-denhaag/button 还在维护吗?

最新版本 3.2.0 发布于 2026/10/05(1 个月前);至今共发布 440 个版本,其中过去 12 个月发布了 8 个;首次发布于 2021/03/20。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。