Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
matthunz authored Sep 24, 2023
1 parent c9a7af2 commit ecaa64a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ but you can bring your own state management tools or build your own framework us
- Accessibility with [accesskit](https://github.com/AccessKit/accesskit)
- High performance rendering with [rust-skia](https://github.com/rust-skia/rust-skia)

## Examples

### Hello World
```rust
let mut tree = Tree::default();
let root = Element::builder()
Expand All @@ -45,12 +48,13 @@ let root = Element::builder()
viewbuilder::run(tree, root)
```

### Button Component
```rust
fn button(tree: &mut Tree, mut f: impl FnMut(&mut Tree) + 'static) -> DefaultKey {
fn button(tree: &mut Tree, mut f: impl FnMut(&mut Tree) + 'static) -> ElementKey {
Element::builder()
.on_click(Box::new(move |tree, _event| f(tree)))
.background_color(Color4f::new(1., 1., 0., 1.))
.child(tree.insert("More!"))
.build(tree)
}
```
```

0 comments on commit ecaa64a

Please sign in to comment.