Skip to content

Button 按钮

用于触发操作,支持多种类型、尺寸、状态、圆角、块级、图标和自定义颜色。下面的示例按亮色主题和深色主题成组展示,便于直接对比。

按钮类型

Light
Dark
vue
<MoButton>Default</MoButton>
<MoButton type="ghost">Ghost</MoButton>
<MoButton type="primary">Primary</MoButton>
<MoButton type="secondary">Secondary</MoButton>
<MoButton type="gradient">Gradient</MoButton>
<MoButton type="success">Success</MoButton>
<MoButton type="warning">Warning</MoButton>
<MoButton type="danger">Danger</MoButton>

<MoButton theme="dark">Default</MoButton>
<MoButton theme="dark" type="primary">Primary</MoButton>

按钮尺寸

Light
Dark
vue
<MoButton size="small" type="primary">Small</MoButton>
<MoButton type="primary">Default</MoButton>
<MoButton size="large" type="primary">Large</MoButton>

禁用与加载

Light
Dark
vue
<MoButton disabled>Disabled</MoButton>
<MoButton type="primary" disabled>Disabled Primary</MoButton>
<MoButton loading>Loading</MoButton>
<MoButton type="primary" loading>Loading Primary</MoButton>

圆角与块级

Light
Dark
vue
<MoButton round>Round</MoButton>
<MoButton round type="primary">Round Primary</MoButton>
<MoButton block type="gradient">Block Button</MoButton>

图标与插槽

Light
Dark
vue
<MoButton type="primary">
  <template #prefix>+</template>
  新建
</MoButton>

<MoButton type="secondary">
  下一步
  <template #suffix>→</template>
</MoButton>

<MoButton icon aria-label="刷新">
  <template #icon>↻</template>
</MoButton>

自定义颜色

Light
Dark
vue
<MoButton
  background-color="#111827"
  border-color="#111827"
  text-color="#ffffff"
>
  深色填充
</MoButton>

API

属性说明类型默认值
type按钮类型default | ghost | primary | secondary | gradient | success | warning | dangerdefault
size尺寸small | default | largedefault
theme主题light | darklight
disabled是否禁用booleanfalse
loading是否加载中booleanfalse
round是否圆角胶囊booleanfalse
icon是否图标按钮booleanfalse
block是否占满父容器宽度booleanfalse
backgroundColor自定义背景色string-
borderColor自定义边框色string-
textColor自定义文字色string-

Events

事件说明参数
click点击按钮时触发;禁用或加载中不会触发MouseEvent

Slots

插槽说明
default按钮内容
icon图标内容;无默认插槽时会展示为纯图标按钮
prefix前置内容,纯图标按钮下不展示
suffix后置内容,纯图标按钮下不展示