@ray-js/smart-ui 2.13.1 → 2.13.2-beta-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/@types/config-provider/index.d.ts +7 -2
- package/es/@types/config-provider/theme-vars.d.ts +1 -1
- package/es/action-sheet/README.md +613 -0
- package/es/battery/README.md +149 -0
- package/es/bottom-sheet/README.md +495 -0
- package/es/button/README.md +335 -0
- package/es/calendar/README.md +513 -0
- package/es/cascader/README.md +326 -0
- package/es/cell/README.md +317 -0
- package/es/checkbox/README.md +481 -0
- package/es/circle/README.md +132 -0
- package/es/col/README.md +162 -0
- package/es/collapse/README.md +127 -0
- package/es/config-provider/README.md +150 -0
- package/es/count-down/README.md +201 -0
- package/es/custom-keyboard/README.md +122 -0
- package/es/datetime-picker/README.md +438 -0
- package/es/dialog/README.md +451 -0
- package/es/divider/README.md +132 -0
- package/es/dropdown-menu/README.md +331 -0
- package/es/empty/README.md +119 -0
- package/es/field/README.md +455 -0
- package/es/grid/README.md +273 -0
- package/es/icon/README.md +178 -0
- package/es/image/README.md +225 -0
- package/es/index-bar/README.md +186 -0
- package/es/loading/README.md +120 -0
- package/es/nav-bar/README.md +410 -0
- package/es/notice-bar/README.md +274 -0
- package/es/notify/README.md +121 -0
- package/es/overlay/README.md +128 -0
- package/es/picker/README.md +412 -0
- package/es/popover/README.md +338 -0
- package/es/popup/README.md +272 -0
- package/es/progress/README.md +88 -0
- package/es/radio/README.md +423 -0
- package/es/rate/README.md +248 -0
- package/es/search/README.md +290 -0
- package/es/sidebar/README.md +176 -0
- package/es/skeleton/README.md +141 -0
- package/es/slider/README.md +444 -0
- package/es/stepper/README.md +231 -0
- package/es/sticky/README.md +91 -0
- package/es/swipe-cell/README.md +217 -0
- package/es/switch/README.md +316 -0
- package/es/tab/README.md +501 -0
- package/es/tabbar/README.md +397 -0
- package/es/tag/README.md +215 -0
- package/es/toast/README.md +293 -0
- package/es/transition/README.md +140 -0
- package/es/tree-select/README.md +348 -0
- package/lib/@types/config-provider/index.d.ts +7 -2
- package/lib/@types/config-provider/theme-vars.d.ts +1 -1
- package/lib/action-sheet/README.md +613 -0
- package/lib/battery/README.md +149 -0
- package/lib/bottom-sheet/README.md +495 -0
- package/lib/button/README.md +335 -0
- package/lib/calendar/README.md +513 -0
- package/lib/cascader/README.md +326 -0
- package/lib/cell/README.md +317 -0
- package/lib/checkbox/README.md +481 -0
- package/lib/circle/README.md +132 -0
- package/lib/col/README.md +162 -0
- package/lib/collapse/README.md +127 -0
- package/lib/config-provider/README.md +150 -0
- package/lib/count-down/README.md +201 -0
- package/lib/custom-keyboard/README.md +122 -0
- package/lib/datetime-picker/README.md +438 -0
- package/lib/dialog/README.md +451 -0
- package/lib/divider/README.md +132 -0
- package/lib/dropdown-menu/README.md +331 -0
- package/lib/empty/README.md +119 -0
- package/lib/field/README.md +455 -0
- package/lib/grid/README.md +273 -0
- package/lib/icon/README.md +178 -0
- package/lib/image/README.md +225 -0
- package/lib/index-bar/README.md +186 -0
- package/lib/loading/README.md +120 -0
- package/lib/nav-bar/README.md +410 -0
- package/lib/notice-bar/README.md +274 -0
- package/lib/notify/README.md +121 -0
- package/lib/overlay/README.md +128 -0
- package/lib/picker/README.md +412 -0
- package/lib/popover/README.md +338 -0
- package/lib/popup/README.md +272 -0
- package/lib/progress/README.md +88 -0
- package/lib/radio/README.md +423 -0
- package/lib/rate/README.md +248 -0
- package/lib/search/README.md +290 -0
- package/lib/sidebar/README.md +176 -0
- package/lib/skeleton/README.md +141 -0
- package/lib/slider/README.md +444 -0
- package/lib/stepper/README.md +231 -0
- package/lib/sticky/README.md +91 -0
- package/lib/swipe-cell/README.md +217 -0
- package/lib/switch/README.md +316 -0
- package/lib/tab/README.md +501 -0
- package/lib/tabbar/README.md +397 -0
- package/lib/tag/README.md +215 -0
- package/lib/toast/README.md +293 -0
- package/lib/transition/README.md +140 -0
- package/lib/tree-select/README.md +348 -0
- package/package.json +3 -3
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
---
|
|
2
|
+
category: 通用
|
|
3
|
+
assets: CircleHandle,PressKey,TyFinger,DoubleKey
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Button 按钮
|
|
7
|
+
|
|
8
|
+
### 介绍
|
|
9
|
+
|
|
10
|
+
按钮用于触发一个操作,如提交表单。
|
|
11
|
+
|
|
12
|
+
### 引入
|
|
13
|
+
|
|
14
|
+
```jsx
|
|
15
|
+
import { Button } from '@ray-js/smart-ui';
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## 代码演示
|
|
19
|
+
|
|
20
|
+
### 按钮类型
|
|
21
|
+
|
|
22
|
+
支持`default`、`primary`、`info`、`warning`、`danger`五种类型,默认为`default`。
|
|
23
|
+
|
|
24
|
+
```jsx
|
|
25
|
+
import React from 'react';
|
|
26
|
+
import { Button } from '@ray-js/smart-ui';
|
|
27
|
+
import { View } from '@ray-js/ray';
|
|
28
|
+
|
|
29
|
+
export default function Demo() {
|
|
30
|
+
return (
|
|
31
|
+
<View>
|
|
32
|
+
<Button type="default">默认按钮</Button>
|
|
33
|
+
<Button type="primary">主要按钮</Button>
|
|
34
|
+
<Button type="info">信息按钮</Button>
|
|
35
|
+
<Button type="warning">警告按钮</Button>
|
|
36
|
+
<Button type="danger">危险按钮</Button>
|
|
37
|
+
</View>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### 朴素按钮
|
|
43
|
+
|
|
44
|
+
通过`plain`属性将按钮设置为朴素按钮,朴素按钮的文字为按钮颜色;默认背景为白色,字体为黑色。
|
|
45
|
+
|
|
46
|
+
```jsx
|
|
47
|
+
import React from 'react';
|
|
48
|
+
import { Button } from '@ray-js/smart-ui';
|
|
49
|
+
import { View } from '@ray-js/ray';
|
|
50
|
+
|
|
51
|
+
export default function Demo() {
|
|
52
|
+
return (
|
|
53
|
+
<View>
|
|
54
|
+
<Button plain>朴素按钮</Button>
|
|
55
|
+
<Button plain type="primary">
|
|
56
|
+
朴素按钮
|
|
57
|
+
</Button>
|
|
58
|
+
<Button plain type="info">
|
|
59
|
+
朴素按钮
|
|
60
|
+
</Button>
|
|
61
|
+
</View>
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### 细边框
|
|
67
|
+
|
|
68
|
+
设置`hairline`属性可以开启 0.5px 边框,基于伪类实现。
|
|
69
|
+
|
|
70
|
+
```jsx
|
|
71
|
+
import React from 'react';
|
|
72
|
+
import { Button } from '@ray-js/smart-ui';
|
|
73
|
+
import { View } from '@ray-js/ray';
|
|
74
|
+
|
|
75
|
+
export default function Demo() {
|
|
76
|
+
return (
|
|
77
|
+
<View>
|
|
78
|
+
<Button plain hairline type="primary">
|
|
79
|
+
细边框按钮
|
|
80
|
+
</Button>
|
|
81
|
+
<Button plain hairline type="info">
|
|
82
|
+
细边框按钮
|
|
83
|
+
</Button>
|
|
84
|
+
</View>
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### 禁用状态
|
|
90
|
+
|
|
91
|
+
通过`disabled`属性来禁用按钮,此时按钮的`bind:click`事件不会触发。
|
|
92
|
+
|
|
93
|
+
```jsx
|
|
94
|
+
import React from 'react';
|
|
95
|
+
import { Button } from '@ray-js/smart-ui';
|
|
96
|
+
import { View } from '@ray-js/ray';
|
|
97
|
+
|
|
98
|
+
export default function Demo() {
|
|
99
|
+
return (
|
|
100
|
+
<View>
|
|
101
|
+
<Button disabled type="primary">
|
|
102
|
+
禁用状态
|
|
103
|
+
</Button>
|
|
104
|
+
<Button disabled type="info">
|
|
105
|
+
禁用状态
|
|
106
|
+
</Button>
|
|
107
|
+
</View>
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### 加载状态
|
|
113
|
+
|
|
114
|
+
```jsx
|
|
115
|
+
import React from 'react';
|
|
116
|
+
import { Button } from '@ray-js/smart-ui';
|
|
117
|
+
import { View } from '@ray-js/ray';
|
|
118
|
+
|
|
119
|
+
export default function Demo() {
|
|
120
|
+
return (
|
|
121
|
+
<View>
|
|
122
|
+
<Button loading type="warning" loadingText="加载中..." />
|
|
123
|
+
<Button loading type="warning" />
|
|
124
|
+
<Button loading type="primary" />
|
|
125
|
+
<Button loading type="primary" loadingType="spinner" />
|
|
126
|
+
</View>
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### 按钮形状
|
|
132
|
+
|
|
133
|
+
```jsx
|
|
134
|
+
import React from 'react';
|
|
135
|
+
import { Button } from '@ray-js/smart-ui';
|
|
136
|
+
import { View } from '@ray-js/ray';
|
|
137
|
+
|
|
138
|
+
export default function Demo() {
|
|
139
|
+
return (
|
|
140
|
+
<View>
|
|
141
|
+
<Button square type="primary">
|
|
142
|
+
方形按钮
|
|
143
|
+
</Button>
|
|
144
|
+
<Button round type="info">
|
|
145
|
+
圆形按钮
|
|
146
|
+
</Button>
|
|
147
|
+
</View>
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### 图标按钮
|
|
153
|
+
|
|
154
|
+
通过`icon`属性设置按钮图标,支持 Icon 组件里的所有图标,也可以传入图标 URL。
|
|
155
|
+
|
|
156
|
+
```jsx
|
|
157
|
+
import React from 'react';
|
|
158
|
+
import { Button } from '@ray-js/smart-ui';
|
|
159
|
+
import { View } from '@ray-js/ray';
|
|
160
|
+
import PlusCircleIcon from '@tuya-miniapp/icons/dist/svg/PlusCircle';
|
|
161
|
+
import RightIcon from '@tuya-miniapp/icons/dist/svg/Right';
|
|
162
|
+
|
|
163
|
+
export default function Demo() {
|
|
164
|
+
return (
|
|
165
|
+
<View>
|
|
166
|
+
<Button icon={PlusCircleIcon} type="primary" />
|
|
167
|
+
<Button icon={RightIcon} type="primary">
|
|
168
|
+
按钮
|
|
169
|
+
</Button>
|
|
170
|
+
<Button
|
|
171
|
+
icon="https://static1.tuyacn.com/static/tuya-miniapp-doc/_next/static/images/logo-small.png"
|
|
172
|
+
type="info"
|
|
173
|
+
>
|
|
174
|
+
按钮
|
|
175
|
+
</Button>
|
|
176
|
+
</View>
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
### 按钮尺寸
|
|
182
|
+
|
|
183
|
+
支持`large`、`normal`、`small`、`mini`四种尺寸,默认为`normal`。
|
|
184
|
+
|
|
185
|
+
```jsx
|
|
186
|
+
import React from 'react';
|
|
187
|
+
import { Button } from '@ray-js/smart-ui';
|
|
188
|
+
import { View } from '@ray-js/ray';
|
|
189
|
+
|
|
190
|
+
export default function Demo() {
|
|
191
|
+
return (
|
|
192
|
+
<View>
|
|
193
|
+
<Button type="primary" size="large">
|
|
194
|
+
大号按钮
|
|
195
|
+
</Button>
|
|
196
|
+
<Button type="primary" size="normal">
|
|
197
|
+
普通按钮
|
|
198
|
+
</Button>
|
|
199
|
+
<Button type="primary" size="small">
|
|
200
|
+
小型按钮
|
|
201
|
+
</Button>
|
|
202
|
+
<Button type="primary" size="mini">
|
|
203
|
+
迷你按钮
|
|
204
|
+
</Button>
|
|
205
|
+
</View>
|
|
206
|
+
);
|
|
207
|
+
}
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
### 块级元素
|
|
211
|
+
|
|
212
|
+
通过`block`属性可以将按钮的元素类型设置为块级元素。
|
|
213
|
+
|
|
214
|
+
```jsx
|
|
215
|
+
import React from 'react';
|
|
216
|
+
import { Button } from '@ray-js/smart-ui';
|
|
217
|
+
import { View } from '@ray-js/ray';
|
|
218
|
+
|
|
219
|
+
export default function Demo() {
|
|
220
|
+
return (
|
|
221
|
+
<View>
|
|
222
|
+
<Button type="primary" block>
|
|
223
|
+
块级元素
|
|
224
|
+
</Button>
|
|
225
|
+
</View>
|
|
226
|
+
);
|
|
227
|
+
}
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
### 自定义颜色
|
|
231
|
+
|
|
232
|
+
通过`color`属性可以自定义按钮的颜色。
|
|
233
|
+
|
|
234
|
+
```jsx
|
|
235
|
+
import React from 'react';
|
|
236
|
+
import { Button } from '@ray-js/smart-ui';
|
|
237
|
+
import { View } from '@ray-js/ray';
|
|
238
|
+
|
|
239
|
+
export default function Demo() {
|
|
240
|
+
return (
|
|
241
|
+
<View>
|
|
242
|
+
<Button color="#7232dd">单色按钮</Button>
|
|
243
|
+
<Button color="#7232dd" plain>
|
|
244
|
+
单色按钮
|
|
245
|
+
</Button>
|
|
246
|
+
<Button color="linear-gradient(to right, #4bb0ff, #6149f6)">渐变色按钮</Button>{' '}
|
|
247
|
+
</View>
|
|
248
|
+
);
|
|
249
|
+
}
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
## API
|
|
253
|
+
|
|
254
|
+
### Props
|
|
255
|
+
|
|
256
|
+
| 参数 | 说明 | 类型 | 默认值 |
|
|
257
|
+
| ------------ | -------------------------------------------------------- | --------- | ------------ |
|
|
258
|
+
| block | 是否为块级元素 | _boolean_ | `false` |
|
|
259
|
+
| buttonId | 标识符,作为原生 button 组件的 id 值 | _string_ | - |
|
|
260
|
+
| classPrefix | 图标类名前缀,同 Icon 组件的 [class-prefix 属性](/material/smartui?comId=icon) | _string_ | `smart-icon` |
|
|
261
|
+
| color | 按钮颜色,支持传入`linear-gradient`渐变色 | _string_ | - |
|
|
262
|
+
| customStyle | 自定义样式 | _React.CSSProperties_ | - |
|
|
263
|
+
| disabled | 是否禁用按钮 | _boolean_ | `false` |
|
|
264
|
+
| hairline | 是否使用 0.5px 边框 | _boolean_ | `false` |
|
|
265
|
+
| icon | 左侧图标或图片链接,可选值见 [Icon 组件](/material/smartui?comId=icon) | _string_ | - |
|
|
266
|
+
| id | 标识符 | _string_ | - |
|
|
267
|
+
| loading | 是否显示为加载状态 | _boolean_ | `false` |
|
|
268
|
+
| loadingSize | 加载图标大小 | _string_ | `20px` |
|
|
269
|
+
| loadingText | 加载状态提示文字 | _string_ | - |
|
|
270
|
+
| textStyle | 按钮文字样式 | _React.CSSProperties_ | - |
|
|
271
|
+
| loadingType | 加载状态图标类型,可选值为 `spinner` | _string_ | `circular` |
|
|
272
|
+
| plain | 是否为朴素按钮 | _boolean_ | `false` |
|
|
273
|
+
| rightIcon | 右侧图标或图片链接,可选值见 [Icon 组件](/material/smartui?comId=icon) | _string_ | - |
|
|
274
|
+
| round | 是否为圆形按钮 | _boolean_ | `false` |
|
|
275
|
+
| size | 按钮尺寸,可选值为 `normal` `large` `small` `mini` | _string_ | `normal` |
|
|
276
|
+
| square | 是否为方形按钮 | _boolean_ | `false` |
|
|
277
|
+
| type | 按钮类型,可选值为 `primary` `info` `warning` `danger` | _string_ | `default` |
|
|
278
|
+
|
|
279
|
+
### Events
|
|
280
|
+
|
|
281
|
+
| 事件名 | 说明 | 参数 |
|
|
282
|
+
| ---------- | ---------------------------------------- | ---- |
|
|
283
|
+
| onClick | 点击按钮,且按钮状态不为加载或禁用时触发 | - |
|
|
284
|
+
| onError | 当使用开放能力时,发生错误的回调 | - |
|
|
285
|
+
|
|
286
|
+
> Button 提供的是 click 事件而不是原生 tap 事件,按钮禁用时,click 事件不会触发,tap 事件依然会触发。
|
|
287
|
+
|
|
288
|
+
### 外部样式类
|
|
289
|
+
|
|
290
|
+
| 类名 | 说明 |
|
|
291
|
+
| ------------- | -------------- |
|
|
292
|
+
| customClass | 根节点样式类 |
|
|
293
|
+
| loadingClass | 加载图标样式类 |
|
|
294
|
+
| hoverClass | 按钮按下时的样式 |
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
### 样式变量
|
|
298
|
+
|
|
299
|
+
组件提供了下列 CSS 变量,可用于自定义样式,使用方法请参考 [ConfigProvider 组件](/material/smartui?comId=config-provider)。
|
|
300
|
+
| 名称 | 默认值 | 描述 |
|
|
301
|
+
| --------------------------------------------- | ---------------------------------------------- | ---------------------------------- |
|
|
302
|
+
| --button-mini-height | _22px_ | 迷你按钮高度 |
|
|
303
|
+
| --button-mini-min-width | _50px_ | 迷你按钮最小宽度 |
|
|
304
|
+
| --button-mini-font-size | _10px_ | 迷你按钮字体大小 |
|
|
305
|
+
| --button-small-height | _30px_ | 小按钮高度 |
|
|
306
|
+
| --button-small-font-size | _12px_ | 小按钮字体大小 |
|
|
307
|
+
| --button-small-min-width | _60px_ | 小按钮最小宽度 |
|
|
308
|
+
| --button-normal-font-size | _14px_ | 普通按钮字体大小 |
|
|
309
|
+
| --button-large-height | _48px_ | 大按钮高度 |
|
|
310
|
+
| --button-default-color | _var(--app-B1-N1, rgba(0, 0, 0, 1))_ | 默认按钮字体颜色 |
|
|
311
|
+
| --button-default-height | _48px_ | 默认按钮高度 |
|
|
312
|
+
| --button-default-font-size | _16px_ | 默认按钮字体大小 |
|
|
313
|
+
| --button-default-background-color | _var(--app-B3, #ffffff)_ | 默认按钮背景颜色 |
|
|
314
|
+
| --button-default-border-color | _var(--app-B6-N7, rgba(0, 0, 0, 0.1))_ | 默认按钮边框颜色 |
|
|
315
|
+
| --button-primary-color | _#fff_ | 主按钮字体颜色 |
|
|
316
|
+
| --button-primary-background-color | _var(--app-M3, #2dda86)_ | 主按钮背景颜色 |
|
|
317
|
+
| --button-primary-border-color | _var(--app-M3, #2dda86)_ | 主按钮边框颜色 |
|
|
318
|
+
| --button-info-color | _#fff_ | 信息按钮字体颜色 |
|
|
319
|
+
| --button-info-background-color | _var(--app-M4, #1989fa)_ | 信息按钮背景颜色 |
|
|
320
|
+
| --button-info-border-color | _var(--app-M4, #1989fa)_ | 信息按钮边框颜色 |
|
|
321
|
+
| --button-danger-color | _#fff_ | 危险按钮字体颜色 |
|
|
322
|
+
| --button-danger-background-color | _var(--app-M2, #f04c4c)_ | 危险按钮背景颜色 |
|
|
323
|
+
| --button-danger-border-color | _var(--app-M2, #f04c4c)_ | 危险按钮边框颜色 |
|
|
324
|
+
| --button-warning-color | _#fff_ | 警告按钮字体颜色 |
|
|
325
|
+
| --button-warning-background-color | _var(--app-M5, #ffa000)_ | 警告按钮背景颜色 |
|
|
326
|
+
| --button-warning-border-color | _var(--app-M5, #ffa000)_ | 警告按钮边框颜色 |
|
|
327
|
+
| --button-line-height | _20px_ | 按钮行高 |
|
|
328
|
+
| --button-border-width | _1px_ | 按钮边框宽度 |
|
|
329
|
+
| --button-border-radius | _10px_ | 按钮边框圆角半径 |
|
|
330
|
+
| --button-round-border-radius | _999px_ | 圆形按钮边框圆角半径 |
|
|
331
|
+
| --button-plain-color `v2.13.2` | _rgba(0, 0, 0, 0.9)_ | 纯按钮文字颜色 |
|
|
332
|
+
| --button-plain-background-color | _#fff_ | 纯按钮背景颜色 |
|
|
333
|
+
| --button-disabled-opacity | _0.3_ | 禁用按钮不透明度 |
|
|
334
|
+
| --button-font-weight | _normal_ | 按钮字体粗细 |
|
|
335
|
+
| --button-primary-font-weight | _600_ | 主按钮字体粗细 |
|