Skip to content

Commit

Permalink
docs
Browse files Browse the repository at this point in the history
  • Loading branch information
marc2332 committed Nov 7, 2023
1 parent 9c45732 commit 25c6d9f
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions book/src/guides/layout.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ Learn how the layout attributes work.
- [`min_width & min_height`](#min_width--min_height)
- [`max_width & max_height`](#max_width--max_height)
- [`Size units`](#size_units)
- [`auto`](#auto)
- [`Logical pixels`](#logical-pixels)
- [`Percentages`](#percentages)
- [`calc()`](#calc)
- [`fill`](#fill)
- [`direction`](#direction)
- [`padding`](#padding)
- [`margin`](#margin)
Expand Down Expand Up @@ -81,6 +83,23 @@ fn app(cx: Scope) -> Element {

### Size Units

#### Auto
Will use it's inner children as size, so in this case, the `rect` width will be defined bu the width of `label`:

```rust, no_run
fn app(cx: Scope) -> Element {
render!(
rect {
width: "auto",
height: "33",
label {
"hello!"
}
}
)
}
```

#### Logical pixels

```rust, no_run
Expand Down Expand Up @@ -108,6 +127,28 @@ fn app(cx: Scope) -> Element {
}
```

#### fill
Use the remaining available space from the parent area:

```rust, no_run
fn app(cx: Scope) -> Element {
render!(
rect {
width: "100%",
height: "100%",
rect {
height: "200",
width: "100%",
}
rect {
height: "fill", // This is the same as calc(100% - 200)
width: "100%",
}
}
)
}
```

#### `calc()`

For more complex logic you can use the `calc()` function.
Expand Down

0 comments on commit 25c6d9f

Please sign in to comment.