Skip to content

Button 按钮

常用的操作触发器。支持七种视觉类型、三种尺寸、加载态、禁用态以及图标插槽。

基础用法

类型、状态与尺寸

类型、尺寸、禁用和 loading 状态集中展示,点击加载按钮可观察即时状态变化。

vue

菜单式按钮

每个选项通过 selected-color 传入 rgb()rgba() 等颜色值,选中背景由组件自动生成。

vue

使用建议

  • 一个操作区域通常只保留一个 primary 按钮,避免多个主操作争夺注意力。
  • 异步提交期间使用 loading。加载状态会同时禁用按钮,防止重复提交。
  • 只有图标的按钮应提供 aria-label,让读屏软件能够说明按钮用途。
  • 关闭入口直接使用 <AuButton :icon="IconX" circle aria-label="关闭" />,其中 IconXaurora-plus 导入。
  • 表单内若不希望触发表单提交,保留默认的 native-type="button"

Button API

Attributes

属性说明类型可选值默认值
type视觉类型stringdefault / primary / success / info / warning / danger / menudefault
size按钮尺寸stringsmall / default / largedefault
selected是否选中;设置后同步输出 aria-pressedbooleanundefined
selectedColormenu 类型的选中颜色,背景由组件自动生成string十六进制、rgb()rgba() 等颜色值''
nativeType原生 buttontypestringbutton / submit / resetbutton
icon图标组件Componentnull
plain是否使用朴素样式booleanfalse
round是否使用胶囊圆角booleanfalse
circle是否为圆形图标按钮booleanfalse
disabled是否禁用booleanfalse
loading是否显示加载状态;开启时按钮不可点击booleanfalse

未被组件声明的属性(例如 aria-labelautofocusform)会透传到原生 <button>

Events

事件名说明参数
click按钮可用且不处于加载状态时触发(event: MouseEvent)

Slots

插槽名说明
default按钮文字或其他内容
icon覆盖 icon 属性对应的默认图标
loading覆盖加载状态的默认旋转图标

Aurora Plus · Vue 3 Component Library