Component

Button

安装 Installation

npx timkit add button --yes --framework react

用法 Usage

import { Button } from "@/components/ui/button"

className 与 variant、size 可以一起用。字段以 timkit agent inspect button --json 的 props 为准。

示例

Examples

一次看一个示例。左侧按名称筛选,预览里可切换源码和框架。

54 / 54

Button · Pattern 01

Loading preview...

结构化 API

Structured API

与 UCS schema 对齐的 props、逻辑机与多框架运行时。

Component

button

Logic

none

Runtime Frameworks

ReactVueWeappHTML

Supported Platforms

WebWeChat Mini Program

Configuration

PropTypeDefaultDescription
logic.provider*
enum (zag | native | none)
noneState and interaction provider used by this component.
logic.machine
string
-Underlying state machine identifier when provider is zag.
platforms*
array
Web, WeChat Mini ProgramPlatforms officially supported by this schema.
frameworks*
array
React, Vue, Weapp, HTMLFramework demos/code currently available in registry files.
dependencies
array
@timui/coreRuntime package dependencies required by this registry item.
optionalPeerDependencies
array
-Optional peer dependencies used by this registry item.
registryDependencies
array
-Dependent Timkit registry components/hook entries.

Props

PropTypeDefaultDescription
label
string
-Visible text label displayed inside the button body。
variant
enum (default | destructive | outline | secondary | ghost | link)
defaultSemantic styling preset that maps to shared design tokens。
size
enum (default | sm | lg | icon)
defaultControls the padding and typography size。
disabled
boolean
falseMarks the action as unavailable and prevents pointer / tap。
loading
boolean
falseShows a busy indicator and disables interactions。

Events

PropTypeDefaultDescription
onPress
event
-Callback that fires when the user clicks / taps the button。

TypeScript

来自 TypeScript 导出。

PropTypeDefaultDescription
asChild
boolean
-Change the default rendered element for the one passed as a child, merging their props and behavior.

Slots

PropTypeDefaultDescription
icon-left
slot
-Optional leading icon rendered before the label。
default*
slot
-The button label content,默认渲染 `label` prop。
icon-right
slot
-Optional trailing icon rendered after the label。

Parts

PropTypeDefaultDescription
root*
root
-The button element itself
label
part
-The text label inside the button
icon
part
-Optional icon element

Variants

variantdefault: default

Visual intent of the button。

defaultdestructiveoutlinesecondaryghostlink

sizedefault: default

Available control sizes。

defaultsmlgicon

Interaction States

press

Button reacts to tap / click with hover + active states。

defaulthoveractivedisabledloading
This API reference is generated from `/packages/core` component schemas to keep React/Vue/Weapp docs consistent.

该组件尚无扩展说明文档。

键盘与焦点

Keyboard

跨 React、Vue 与小程序共享的交互与可读名称约定。

  • A loading button ignores presses and sets aria-busy.
  • A loading button is visible as Loading.
  • A button that is not loading has no loading status.
  • A disabled button ignores presses.
  • On the mini program, the loading mark is not part of the button name.
  • An omitted type is button on React and in Vue.
  • A passed type submit still submits.
  • In static HTML, the button is type button.
  • On the mini program, an omitted form type does not submit.