Skip to content

Button 按钮 ​

显示一个按钮,或看起来像按钮的组件。

变体 ​

网页近似预览,真机效果以 HarmonyOS 渲染为准。

尺寸 ​

网页近似预览,真机效果以 HarmonyOS 渲染为准。

图标与状态 ​

网页近似预览,真机效果以 HarmonyOS 渲染为准。

块级与加载文案 ​

block 撑满父容器宽度;loadingText 在加载时替换按钮文字。

网页近似预览,真机效果以 HarmonyOS 渲染为准。

API ​

从组件库源码中的 @Param / @Event / @BuilderParam 声明自动提取。

SButton ​

shadcn-vue 的 Button。

点击使用原生通用事件(直接在 SButton 上使用 .onClick(),与 Vue 的 @click 相同);在 disabled / loading 状态下,内部的空操作点击手势会吞掉点击(参见 SparkTapBlocker)。

属性类型默认值说明
textResourceStr | undefinedundefined
variantButtonVariant
ButtonVariant = 'default' | 'destructive' | 'outline' | 'secondary' | 'ghost' | 'link'
'default'
sizingButtonSize
ButtonSize = 'default' | 'sm' | 'lg' | 'icon' | 'icon-sm' | 'icon-lg'
'default'
disabledbooleanfalse
loadingbooleanfalse显示加载指示器并禁用按钮。
loadingTextResourceStr | undefinedundefinedloading 时代替 text 显示的文字。
blockbooleanfalse占满父容器的宽度(w-full)。
iconstring | undefinedundefined前导 lucide 图标名称。
iconRightstring | undefinedundefined尾部 lucide 图标名称。
labelstring | undefinedundefined无障碍名称;纯图标按钮必须设置。
modifierAttributeModifier<ButtonAttribute>new SparkNoopModifier<ButtonAttribute>()在变体配方之后应用的额外样式(冲突时以此为准)。
tokensButtonTokens{}实例级令牌覆盖(实例 → 主题 --button-* → 配方),例如 tokens: { radius: 999, background: 'oklch(0.6 0.2 250)' }。参见 ADR D13。
pressFeedbackSparkPressFeedback
SparkPressFeedback = 'background' | 'opacity' | 'none'
'background'按下反馈:'background'(操作类,默认)、'opacity'(选择类条目)、'none'。

插槽: 子组件(尾随闭包)

MIT Licensed