Skip to content

Button 按钮

常用的操作按钮。

何时使用

按钮用于开始一个即时操作。

基本使用

不同尺寸

禁用状态

圆角按钮

圆形按钮

朴素按钮

加载状态

图标按钮

自定义颜色 color

color 接受任意 CSS color 字符串。实心 type(primary/success/warning/danger/info)注入 background-color + border-color;描边 type(''/default/dashed)注入 color + border-colortext/link 仅注入 color。hover/active 联动由使用方用 CSS class 自兜底。

Button参数

参数类型默认说明
sizeButtonSizeType--尺寸
typeButtonType--类型:'primary' | 'default' | 'dashed' | 'link' | 'text',加语义色 'success' | 'warning' | 'danger' | 'info'
plainbooleanfalse朴素按钮:背景透明,文字与边框跟主色
roundbooleanfalse圆角按钮
circlebooleanfalse圆形按钮(常用于纯图标场景)
native-typeButtonNativeTypebutton原生 <button> 的 type 属性
dangerbooleanfalse危险按钮(与 type 任意值叠加,渲染 --dangerous 类)
ghostbooleanfalse幽灵按钮(透明背景 + 描边色)
blockbooleanfalse撑满父宽度
autoInsertSpacebooleantrue两个 CJK 字符之间自动插入空格
hrefstring--设置后用 <a role="button"> 渲染
targetstring--配合 href 透传 target
iconstringVNode--
iconPosition'start''end'start
disabledbooleanfalse是否为禁用状态
autofocusbooleanfalse原生 autofocus 属性
loadingboolean{ delay?: number; icon?: VNodestring }
colorstring--自定义按钮颜色(任意 CSS color 字符串);实心型 type 注入 bg + border;描边型注入 color + border;text/link 仅 color

ButtonGroup 参数

ButtonGroup<c-button-group>):按钮组,向子按钮注入 size / disabled,并让相邻边框对齐。

参数类型默认说明
size'large''default''small'
disabledbooleanfalse注入给所有子按钮

Button类型定义

ButtonType

ts
export type ButtonType =
  // 标准取值
  | 'primary'
  | 'default'
  | 'dashed'
  | 'link'
  | 'text'
  // 语义色快捷
  | 'success'
  | 'warning'
  | 'danger'
  | 'info'

ButtonSizeType

ts
export type ButtonSizeType = 'large' | 'default' | 'small'

ButtonNativeType

ts
export type ButtonNativeType = 'button' | 'submit' | 'reset'

Button插槽

插槽名说明
icon自定义图标组件

Released under the MIT License.