Button 按钮

按钮组件,支持多种主题、尺寸、形状和变体,参考TDesign设计风格

按钮组件,支持多种主题、尺寸、形状和变体,参考TDesign设计风格

演示

9:41

代码示例

<!-- 主题色 -->
  <re-button content="默认" />
  <re-button theme="primary" content="主要" />
  <re-button theme="danger" content="危险" />
  <re-button theme="warning" content="警告" />
  <re-button theme="success" content="成功" />

<!-- 尺寸 -->
  <re-button size="small" content="小" />
  <re-button size="medium" content="中" />
  <re-button size="large" content="大" />

<!-- 形状 -->
  <re-button shape="rectangle" content="矩形" />
  <re-button shape="round" content="圆角" />
  <re-button shape="square" content="方形" />
  <re-button shape="circle" content="圆" />

<!-- 变体 -->
  <re-button variant="base" theme="primary" content="基础" />
  <re-button variant="outline" theme="primary" content="描边" />
  <re-button variant="text" theme="primary" content="文字" />
  <re-button variant="dashed" theme="primary" content="虚线" />

<!-- 块级按钮 -->
  <re-button :block="true" theme="primary" content="块级按钮" />

<!-- 禁用状态 -->
  <re-button :disabled="true" content="禁用" />
  <re-button :disabled="true" theme="primary" content="禁用主要" />

<!-- 加载状态 -->
  <re-button :loading="true" content="加载中" />
  <re-button :loading="true" theme="primary" content="加载中" />

<!-- 图标按钮 -->
  <re-button icon="★" content="字体图标" />
  <re-button icon="★" />
  <re-button icon="/static/logo.png" content="图片图标" />

<!-- 内容与插槽 -->
  <re-button content="内容按钮" />
  <re-button />
  <re-button theme="primary"> <text class="re-button__text">插槽内容</text> </re-button>

<!-- 自定义样式 -->
  <re-button customStyle="background-color: #0052d9; color: #ffffff; border-radius: 9999px;" content="自定义样式" />

引入

推荐使用 easycom 模式,配置后无需手动 import 即可直接使用 <re-button />。

API

Button Props

名称类型默认值描述必传
themestring"default"按钮主题风格,可选值:default/primary/danger/warning/successN
sizestring"medium"按钮尺寸,可选值:small/medium/largeN
shapestring"rectangle"按钮形状,可选值:rectangle/round/square/circleN
variantstring"base"按钮变体类型,可选值:base/outline/text/dashedN
blockbooleanfalse是否为块级元素,占满父容器宽度N
disabledbooleanfalse是否禁用按钮N
loadingbooleanfalse是否显示加载状态N
iconstring""按钮图标,支持字体图标名称或图片地址N
contentstring""按钮文字内容N
customStylestring""自定义样式N
customClassstring""自定义类名N

Button Events

名称参数描述
click-点击按钮时触发

Button Slots

名称描述
default默认插槽