pumpkin-ui
指南
组件
指南
组件
  • 基础组件

    • Button 按钮
    • Cell 单元格
    • Icon 图标
    • Popup 弹出层
    • Toast 轻提示
  • 表单组件

    • PickerView 选择器视图
    • Picker 选择器
    • DatePicker 日期时间选择器
    • Switch 开关
    • Field 输入项
    • Form 表单
    • Checkbox 复选框
    • Radio 单选框
  • 反馈组件

    • Overlay 遮罩
    • Loading 加载
    • ActionSheet 动作面板
    • Notify 消息提示
    • Skeleton 骨架屏
    • Dialog 对话框
  • 展示组件

    • Progress 进度条
    • Divider 分割线
    • Badge 徽标
    • Empty 空元素
    • Tag 标签

Button 按钮

基本使用

<pk-button>按钮</pk-button>

代码示例

按钮类型

按钮有五种类型:主要按钮primary、朦胧按钮hazy、边框按钮outline、幽灵按钮ghost和链接按钮link。

vue
<pk-button type="primary">主要按钮 primary</pk-button>
<pk-button type="hazy">朦胧按钮 hazy</pk-button>
<pk-button type="outline">边框按钮 outline</pk-button>
<pk-button type="ghost">幽灵按钮 ghost</pk-button>
<pk-button type="link">链接按钮 link</pk-button>

子文案

通过 sub-text 设置。

vue
<pk-button type="primary" sub-text="我是子文案我是子文案">主要按钮 primary</pk-button>
<pk-button type="hazy" sub-text="我是子文案">朦胧按钮 hazy</pk-button>
<pk-button type="outline" sub-text="我是子文案我是子文案我是子文案">边框按钮 outline</pk-button>
<pk-button type="ghost" sub-text="我是子文案我是子文案我是子文案我是子文案我是子文案我是子文案我是子文案我是子文案我是子文案我是子文案">幽灵按钮 ghost</pk-button>
<pk-button type="link" sub-text="我是子文案">链接按钮 link</pk-button>

按钮尺寸

按钮有五种尺寸:大按钮xl、大按钮l、中按钮m、小按钮s和超小按钮xs。

vue
<pk-button type="primary" size="xl">大按钮 xl</pk-button>
<pk-button type="primary" size="l">大按钮 l</pk-button>
<pk-button type="primary" size="m">中按钮 m</pk-button>
<pk-button type="primary" size="s">小按钮 s</pk-button>
<pk-button type="primary" size="xs">超小按钮 xs</pk-button>

圆形按钮

通过设置round属性为true,可设置圆形按钮。

vue
<pk-button type="primary" sub-text="我是子文案我是子文案" round>圆形按钮</pk-button>
<pk-button type="primary" round>圆形按钮</pk-button>

方形按钮

通过设置square属性为true,可设置方形按钮。

vue
<pk-button type="primary" sub-text="我是子文案我是子文案" square>方形按钮</pk-button>
<pk-button type="primary" square>方形按钮</pk-button>

块级元素

通过设置block属性为true,可设置块级元素。

vue
<pk-button type="primary" sub-text="我是子文案我是子文案" block>块级元素</pk-button>
<pk-button type="primary" block>块级元素</pk-button>

设置禁用

通过设置disabled属性为true,可设置禁用。

vue
<pk-button type="primary" sub-text="我是子文案我是子文案" disabled>禁用按钮</pk-button>
<pk-button type="primary" disabled>禁用按钮</pk-button>

危险按钮

通过设置danger属性为true,可设置危险按钮。

vue
<pk-button type="primary" sub-text="我是子文案我是子文案" danger>危险按钮</pk-button>
<pk-button type="primary" danger>危险按钮</pk-button>

警告按钮

通过设置warning属性为true,可设置警告按钮。

vue
<pk-button type="primary" sub-text="我是子文案我是子文案" warning>警告按钮</pk-button>
<pk-button type="primary" warning>警告按钮</pk-button>

自定义颜色

通过设置color属性设置自定义颜色。

vue
<pk-button type="primary" sub-text="我是子文案我是子文案" color="#65da79">自定义文字颜色</pk-button>
<pk-button type="primary" color="linear-gradient(90deg,#F83600 0%,#F9D423 100%)">自定义文字颜色</pk-button>

自定义文字颜色

通过设置text-color属性设置自定义文字颜色。

vue
<pk-button type="primary" text-color="#000000" color="#ffffff">自定义颜色</pk-button>
<pk-button type="primary" text-color="#000000"
    color="linear-gradient(90deg,#F83600 0%,#F9D423 100%)">渐变色</pk-button>

加载状态

通过设置loading属性为true,可设置加载状态。通过loading-size设置加载图标的大小,通过设置loading-type设置加载图标的类型。

vue
<pk-button type="primary" loading>默认图标样式</pk-button>
<pk-button type="primary" loading loading-type="spinner">spinner图标样式</pk-button>
<pk-button type="primary" loading loading-type="circular" loading-size="35px">35px</pk-button>

API

Props

属性名说明类型默认值可选值
type按钮类型'primary'| 'hazy'| 'outline'| 'ghost'|'link'primary'primary'| 'hazy'| 'outline'| 'ghost'|'link'
native-typebutton标签的原生type属性'button'| 'submit'| 'reset'button'button'| 'submit'| 'reset'
text按钮上的文字,也可以通过slotstring
sub-text按钮上的字文案string
size按钮尺寸'xl'| 'l'| 'm'| 's'|'xs'm'xl'| 'l'| 'm'| 's'|'xs'
round圆形按钮booleanfalse
square方形按钮booleanfalse
block块级元素booleanfalse
disabled是否禁用booleanfalse
danger设置危险按钮booleanfalse
warning设置警告按钮booleanfalse
color按钮的背景色string
text-color按钮的文字颜色string
border-color按钮的边框颜色string
loading设置加载按钮booleanfalse
loading-size设置加载图标的大小string20px
loading-type设置加载图标的样式,与loading组件的type属性一致'circular'| 'spinner'circular'circular'| 'spinner'

Events

事件名说明回调参数
click点击按钮时触发(不为禁用或者加载状态)(event: MouseEvent) => void

Slots

插槽名说明
default按钮主内容区域
sub子文案区域(生效需要sub-text值不为空)
loading加载图标区域(生效需要设置loading为true)

示例

vue
<pk-button type="primary" loading sub-text="子文案">
            主内容区域
    <template #sub>
        字文案区域
    </template>
    <template #loading>
        加载图标区域
    </template>
</pk-button>

Exposes

名称说明类型说明

样式变量

名称默认值说明
--pk-button-line-height-xs1.1
--pk-button-line-height-s1.2
--pk-button-line-height-m1.7
--pk-button-line-height-l2
--pk-button-line-height-xl2.5
--pk-button-line-height-sub1.53
--pk-button-z-index-textvar(--pk-z-index-min)
--pk-button-z-index-maskvar(--pk-z-index-min-2)
--pk-button-primary-backgroundvar(--pk-primary-color)
--pk-button-primary-border-colorvar(--pk-primary-color)
--pk-button-primary-text-colorvar(--pk-primary-color)
Last Updated:
Contributors: yranky
Next
Cell 单元格