# Layout, Modifiers & Insets (https://crow.build/docs/ui/layout)

**`crow-ui`** is Crow's native Android rendering engine. Every container maps directly to a compact `LNode` backed by hardware `RenderNode` display-list chunks, incremental linear layout, and measure caching.

## Core Containers [#core-containers]

Crow provides the familiar declarative layout primitives:

- **`Box`** — stacked layers with `contentAlignment` (`Alignment.Center`, `Alignment.BottomEnd`, etc.) and `Modifier.align(...)`.
- **`Row` & `Column`** — linear layout with `horizontalArrangement` / `verticalArrangement`, `Arrangement.spacedBy(12.dp)`, cross-axis alignment, and `Modifier.weight(1f)`.
- **`FlowRow`** — wrapping horizontal chips and tags with spacing.
- **`VerticalScroll` & `HorizontalScroll`** — axis-locked scroll containers with Android 12+ RenderNode stretch overscroll, `ScrollState`, and `NestedScrollConnection`.

## Order-Dependent Modifiers [#order-dependent-modifiers]

Modifiers execute in declaration order, matching Jetpack Compose semantics while fusing zero-allocation fast paths at compile time:

```kotlin
Box(
    Modifier
        .fillMaxWidth()
        .padding(16.dp)                         // outer margin (before background)
        .clip(RoundedCornerShape(16.dp))
        .background(SurfaceColor)
        .border(1.dp, BorderColor, RoundedCornerShape(16.dp))
        .clickable { openDetails() }
        .padding(horizontal = 20.dp, vertical = 14.dp), // inner padding
) {
    Text("Tap to open")
}
```

### Sizing & Callbacks [#sizing--callbacks]

- Fixed & constrained sizing: `size`, `width`, `height`, `fillMaxSize`, `fillMaxWidth`, `fillMaxHeight`, `widthIn`, `heightIn`, `sizeIn`, `defaultMinSize`, `requiredSize`, `wrapContentSize`, `aspectRatio`.
- Live reactive sizing: `height { if (open) 240.dp else 72.dp }` re-measures only in the layout phase with zero remounting.
- Placement callbacks: `onSizeChanged`, `onPlaced`, `onGloballyPositioned`, and `BringIntoViewRequester` — callbacks never fire mid-measure.

## Reactive Window Insets [#reactive-window-insets]

Window insets (status bars, navigation bars, IME keyboard, display cutouts, system gestures) are reactive signals in `UiEnv`:

```kotlin
Column(
    Modifier
        .fillMaxSize()
        .safeDrawingPadding()
        .imePadding(),
) {
    // Reacts to keyboard open/close and rotation in the layout phase only
}
```

Use `statusBarsPadding()`, `navigationBarsPadding()`, `systemBarsPadding()`, `imePadding()`, `displayCutoutPadding()`, or `safeDrawingPadding()`. They fuse just like static padding and update only the affected node on inset changes.

## `Scaffold` & Scroll Choreography [#scaffold--scroll-choreography]

`ScaffoldBase` (and Material's `Scaffold`) coordinates top bars, bottom bars, FABs, and scroll behaviors with automatic inset distribution and **zero per-frame relayout**:

- **Overlay + coupled scroll**: Bars follow content scroll position in the layer phase (`Pinned`, `ScrollAway`, `Collapsible`, `Floating`, `FloatingCollapsible`) with velocity-aware settling.
- **FAB coordination**: `expandedByScroll()` smoothly collapses extended FABs as the user scrolls and keeps the FAB docked above hiding navigation bars.