Skip to content

Button 按钮

常用的操作按钮。

基础用法

使用 typeplainroundcircle 来定义按钮的样式。

<script lang="ts" setup></script>
<template>
  <div class="basic block">
    <ZgButton>Default</ZgButton>
    <ZgButton type="primary">Primary</ZgButton>
    <ZgButton type="success">Success</ZgButton>
    <ZgButton type="info">Info</ZgButton>
    <ZgButton type="warning">Warning</ZgButton>
    <ZgButton type="danger">Danger</ZgButton>
  </div>

  <div class="plain block">
    <ZgButton plain>Plain</ZgButton>
    <ZgButton type="primary" plain>Primary</ZgButton>
    <ZgButton type="success" plain>Success</ZgButton>
    <ZgButton type="info" plain>Info</ZgButton>
    <ZgButton type="warning" plain>Warning</ZgButton>
    <ZgButton type="danger" plain>Danger</ZgButton>
  </div>

  <div class="round block">
    <ZgButton round>Round</ZgButton>
    <ZgButton type="primary" round>Primary</ZgButton>
    <ZgButton type="success" round>Success</ZgButton>
    <ZgButton type="info" round>Info</ZgButton>
    <ZgButton type="warning" round>Warning</ZgButton>
    <ZgButton type="danger" round>Danger</ZgButton>
  </div>

  <div class="circle block">
    <ZgButton circle> <UserOutlined /></ZgButton>
    <ZgButton type="primary" circle> <ArrowDownOutlined /> </ZgButton>
    <ZgButton type="success" circle> <ArrowUpOutlined /> </ZgButton>
    <ZgButton type="warning" circle> <LoadingOutlined /> </ZgButton>
    <ZgButton type="danger" circle> <SearchOutlined /> </ZgButton>
    <ZgButton type="info" circle> <UserOutlined /> </ZgButton>
    <ZgButton type="primary" loading> </ZgButton>
  </div>

  <div class="disable block">
    <ZgButton disabled>disabled</ZgButton>
    <ZgButton type="primary" disabled>Primary</ZgButton>
    <ZgButton type="success" disabled>Success</ZgButton>
    <ZgButton type="info" disabled>Info</ZgButton>
    <ZgButton type="warning" disabled>Warning</ZgButton>
    <ZgButton type="danger" disabled>Danger</ZgButton>
  </div>
</template>
<style>
.block {
  margin-bottom: 10px;
}
</style>
<script lang="ts" setup></script>
<template>
  <div class="basic block">
    <ZgButton>Default</ZgButton>
    <ZgButton type="primary">Primary</ZgButton>
    <ZgButton type="success">Success</ZgButton>
    <ZgButton type="info">Info</ZgButton>
    <ZgButton type="warning">Warning</ZgButton>
    <ZgButton type="danger">Danger</ZgButton>
  </div>

  <div class="plain block">
    <ZgButton plain>Plain</ZgButton>
    <ZgButton type="primary" plain>Primary</ZgButton>
    <ZgButton type="success" plain>Success</ZgButton>
    <ZgButton type="info" plain>Info</ZgButton>
    <ZgButton type="warning" plain>Warning</ZgButton>
    <ZgButton type="danger" plain>Danger</ZgButton>
  </div>

  <div class="round block">
    <ZgButton round>Round</ZgButton>
    <ZgButton type="primary" round>Primary</ZgButton>
    <ZgButton type="success" round>Success</ZgButton>
    <ZgButton type="info" round>Info</ZgButton>
    <ZgButton type="warning" round>Warning</ZgButton>
    <ZgButton type="danger" round>Danger</ZgButton>
  </div>

  <div class="circle block">
    <ZgButton circle> <UserOutlined /></ZgButton>
    <ZgButton type="primary" circle> <ArrowDownOutlined /> </ZgButton>
    <ZgButton type="success" circle> <ArrowUpOutlined /> </ZgButton>
    <ZgButton type="warning" circle> <LoadingOutlined /> </ZgButton>
    <ZgButton type="danger" circle> <SearchOutlined /> </ZgButton>
    <ZgButton type="info" circle> <UserOutlined /> </ZgButton>
    <ZgButton type="primary" loading> </ZgButton>
  </div>

  <div class="disable block">
    <ZgButton disabled>disabled</ZgButton>
    <ZgButton type="primary" disabled>Primary</ZgButton>
    <ZgButton type="success" disabled>Success</ZgButton>
    <ZgButton type="info" disabled>Info</ZgButton>
    <ZgButton type="warning" disabled>Warning</ZgButton>
    <ZgButton type="danger" disabled>Danger</ZgButton>
  </div>
</template>
<style>
.block {
  margin-bottom: 10px;
}
</style>

Button Attributes

NameDescriptionTypeDefault
size尺寸'large'| 'small'
type类型'primary'| 'success'| 'warning'| 'danger'| 'info'
plain是否为朴素按钮booleanfalse
round是否为圆角按钮booleanfalse
circle是否为圆形按钮booleanfalse
loading是否为加载中状态booleanfalse
disabled按钮是否为禁用状态booleanfalse
autofocus原生 autofocus 属性booleanfalse
native-type原生 type 属性'button'| 'submit'| 'reset'button

Button Slots

插槽名Description
default自定义默认内容
icon自定义图标组件

Released under the MIT License.