# Nested Components

Compose components by nesting them inside each other. Every nested component is a fully independent instance with its own state, so a tree can go as deep as you like without anything leaking across levels.

## Nesting to any depth

A component can even render itself. This `NestedBox` drops in a child of the same type on every click, so you can build an arbitrarily deep tree at runtime. Name a box, add a nested one, and keep going: each level holds its own live input, proving every instance is isolated.

```interlace-demo
NestedBox
```

## Child-to-parent events

Nesting is not just layout, children can talk back. A child calls `emit_to`, addressing its parent by name, and the parent handles it. Here each row emits to the list to remove itself.

```interlace-demo
NestList
```

To broadcast to *every* listening component instead of one named parent, use `emit`. See [Events](/docs/events/) for the full event API.
