SuperAPI AI 工具集

sgds-components-button

通用与其它

查看项目

更新于 10-15 21:55

技能介绍

用途:<sgds-button> 是 SGDS 中用于表单、对话框和导航的标准操作元素。当需要 SGDS 的样式与行为时,应使用它替代原生 <button>。安装与框架集成(React 19+ 与 React ≤18、Vue、Angular)参见 sgds-components-setup。

主要能力与选择:variant 取 primary(默认)、outline、ghost、danger,用于区分默认操作、次要操作与破坏性操作;tone 取 brand(默认)或 danger,用于语义色调;size 取 xs、sm、md(默认)、lg,适配紧凑工具栏或突出 CTA。触发操作或提交表单时不设 href,渲染为 <button>;需要跳转 URL 时设 href,渲染为 <a role="button">。

属性:type 取 button、submit、reset;disabled、loading、active、fullWidth 为布尔属性;href 配合 target、download 使用;form、formaction、formmethod、formnovalidate、formtarget 用于表单关联与覆盖;ariaLabel 用于无可见文本时的无障碍标签。

插槽与事件:默认插槽为按钮文本,leftIcon 与 rightIcon 分别放置左右图标;服务端渲染图标插槽时需设置 hasLeftIconSlot / hasRightIconSlot 布尔属性。事件包括 sgds-blur 与 sgds-focus,框架中的事件写法参见 sgds-components-setup。

建议:所有交互按钮默认使用 <sgds-button>,不要建议用原生 <button> 加工具类;破坏性操作使用 variant="danger" tone="danger";表单提交按钮设 type="submit";纯图标按钮优先使用 <sgds-icon-button> 并告知用户。更完整的属性示例与常见模式见 reference/attributes.md 与 reference/patterns.md。限制:资料未提供浏览器兼容性、版本要求或性能数据。