Button 按钮
触感按钮与扁平按钮的核心交互
Button 按钮
Usage
按钮用于触发明确的动作,建议在界面里保持主次层级清晰:
- 同一界面只保留一个主按钮,避免权重冲突
- 通过
variant与size传递动作层级 - 异步操作必须展示
loading,避免重复触发
Variants
Appearance
基础外观与主次层级组合。
示例即将加载...
Disabled
按钮不可用状态。
示例即将加载...
Loading
点击按钮后进行数据加载操作,在按钮上显示加载状态。
示例即将加载...
Sizes
Button 组件提供除了默认值以外的三种尺寸,可以在不同场景下选择合适的按钮尺寸,尺寸会影响触感与密度。
示例即将加载...
Block
在卡片或表单中使用块级按钮,用于撑满容器的主操作。
示例即将加载...
Shapes
通过 plain / round / circle / dashed 调整形态。
示例即将加载...
Haptics
移动端触觉反馈强化按下感,支持不同震动强度。
示例即将加载...
API Specifications
Button Attributes
| Parameter | Type | Default | Description |
|---|---|---|---|
variant | primary secondary ghost danger success warning info flat bare | - | 视觉风格变体 |
type | primary success warning danger info text | - | 语义 tone 别名。仅在未设置 `variant` 时用于推导视觉变体;`text` 会映射为 `ghost`。 |
size | sm md lg large small mini | 'md' | 按钮尺寸 |
block | boolean | false | 是否块级(撑满容器) |
plain | boolean | false | 是否朴素按钮 |
dashed | boolean | false | 是否虚线按钮 |
round | boolean | false | 是否圆角按钮 |
circle | boolean | false | 是否圆形按钮 |
loading | boolean | false | 是否加载中状态 |
disabled | boolean | false | 是否禁用状态 |
icon | string | - | 图标类名 |
autofocus | boolean | false | 是否默认聚焦 |
native-type | button submit reset | 'button' | 原生 type 属性 |
vibrate | boolean | true | 是否启用震动反馈 |
vibrate-type | light medium heavy bit success warning error | 'light' | 震动类型 |
Parameter
variant
Type
primary
secondary
ghost
danger
success
warning
info
flat
bare
Default
-
Description
视觉风格变体
Parameter
type
Type
primary
success
warning
danger
info
text
Default
-
Description
语义 tone 别名。仅在未设置 `variant` 时用于推导视觉变体;`text` 会映射为 `ghost`。
Parameter
size
Type
sm
md
lg
large
small
mini
Default
'md'
Description
按钮尺寸
Parameter
block
Type
boolean
Default
false
Description
是否块级(撑满容器)
Parameter
plain
Type
boolean
Default
false
Description
是否朴素按钮
Parameter
dashed
Type
boolean
Default
false
Description
是否虚线按钮
Parameter
round
Type
boolean
Default
false
Description
是否圆角按钮
Parameter
circle
Type
boolean
Default
false
Description
是否圆形按钮
Parameter
loading
Type
boolean
Default
false
Description
是否加载中状态
Parameter
disabled
Type
boolean
Default
false
Description
是否禁用状态
Parameter
icon
Type
string
Default
-
Description
图标类名
Parameter
autofocus
Type
boolean
Default
false
Description
是否默认聚焦
Parameter
native-type
Type
button
submit
reset
Default
'button'
Description
原生 type 属性
Parameter
vibrate
Type
boolean
Default
true
Description
是否启用震动反馈
Parameter
vibrate-type
Type
light
medium
heavy
bit
success
warning
error
Default
'light'
Description
震动类型
Button Events
| Parameter | Type | Default | Description |
|---|---|---|---|
click | (event: MouseEvent) => void | - | 点击时触发 |
Parameter
click
Type
(event: MouseEvent) => void
Default
-
Description
点击时触发
类型
import type { TxButtonProps } from '@talex-touch/tuffex'
export interface ButtonProps extends TxButtonProps {}
Composition Notes
Split Button
用于"主操作 + 更多操作"的组合按钮(例如 RUN + …)。
示例即将加载...
Primary + Ghost
主动作 + 次动作组合时使用 primary + ghost 保持层级清晰。
示例即将加载...
Design Principles
- 主按钮始终只有一个,避免操作权重冲突
- 同类操作保持
variant一致,方便用户形成记忆 - 异步操作必须搭配
loading,避免重复触发 - 移动端优先使用
vibrate增强触感反馈 - 强调按压反馈与弹性回弹
- 透明材质与阴影层次需要配合背景使用
- Icon 与文字间距保持一致,避免视觉偏移
Source
查看源码
packages/tuffex/packages/components/src/button/index.ts