Skip to content

Commit 058980b

Browse files
committed
docs(components): add Button component documentation
1 parent 29cc1b3 commit 058980b

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-0
lines changed

docs/en/components/button.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
title: Button component
3+
order: 2
4+
---
5+
6+
# Button
7+
8+
```rust
9+
pub fn button(
10+
args: impl Into<ButtonArgs>,
11+
ripple_state: Arc<RippleState>,
12+
child: impl FnOnce(),
13+
)
14+
```
15+
16+
The `button` component is a button typically used to trigger an action. It can configure background color, border, shadow, and other properties. It supports click interactions and advanced effects such as a ripple animation.
17+
18+
## Arguments
19+
20+
- `args: impl Into<ButtonArgs>`
21+
22+
This argument configures the style and behavior of the `button` component, including background color, border, shadow, corner radius, etc. Use `ButtonArgsBuilder` to construct this argument.
23+
24+
- `ripple_state: Arc<RippleState>`
25+
26+
The state for the click ripple animation. You must provide a valid `RippleState` instance to enable the ripple animation. This differs from the `surface` component, whose `ripple_state` parameter can be passed as `None` to disable the ripple.
27+
28+
- `child: impl FnOnce()`
29+
30+
The child component of the `button`, which can be any `#[tessera]` function.

docs/zhHans/components/button.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
title: Button 组件
3+
order: 2
4+
---
5+
6+
# Button
7+
8+
```rust
9+
pub fn button(
10+
args: impl Into<ButtonArgs>,
11+
ripple_state: Arc<RippleState>,
12+
child: impl FnOnce(),
13+
)
14+
```
15+
16+
`button` 组件是一个按钮组件,通常用作触发某个操作。它可以设置背景颜色、边框、阴影等属性,同时具有点击交互,水波动画等高级效果。
17+
18+
## 参数
19+
20+
- `args: impl Into<ButtonArgs>`
21+
22+
此参数用于配置`button`组件的样式和行为,包括背景颜色、边框、阴影、圆角等属性。可以通过`ButtonArgsBuilder`来构建这个参数。
23+
24+
- `ripple_state: Arc<RippleState>`
25+
26+
此参数为点击水波纹动画的状态,必须传入一个有效的`RippleState`实例,以启用水波纹动画效果。这点不同于`surface`组件,其`ripple_state`参数可以传入`None`来禁用水波纹动画。
27+
28+
- `child: impl FnOnce()`
29+
30+
此参数为`button`组件的子组件,可以是任何`#[tessera]`函数。

0 commit comments

Comments
 (0)