# `PhoenixKitWeb.LayoutHelpers`
[🔗](https://github.com/BeamLabEU/phoenix_kit/blob/v1.7.87/lib/phoenix_kit_web/helpers/layout_helpers.ex#L1)

Helper functions for working with PhoenixKit layouts efficiently.

## Performance: Avoiding Unnecessary Layout Diffs

When using the dashboard layout, **do not pass all assigns**:

    # ❌ BAD - triggers layout diff on ANY assign change
    <PhoenixKitWeb.Layouts.dashboard {assigns}>

    # ✅ GOOD - only passes assigns the layout uses
    <PhoenixKitWeb.Layouts.dashboard {dashboard_assigns(assigns)}>

The `dashboard_assigns/1` function extracts only the assigns the layout
actually needs, preventing unnecessary network traffic when other assigns
(like application-specific data) change.

# `dashboard_assigns`

```elixir
@spec dashboard_assigns(map()) :: map()
```

Extracts only the assigns needed by the dashboard layout.

Use this to avoid unnecessary layout diffs when other assigns change:

    def render(assigns) do
      ~H"""
      <PhoenixKitWeb.Layouts.dashboard {dashboard_assigns(assigns)}>
        <.my_content data={@data} />
      </PhoenixKitWeb.Layouts.dashboard>
      """
    end

This prevents the layout from re-rendering when assigns like `@data`
change, since the layout doesn't use `@data`.

## Performance Impact

Without this optimization, a LiveView receiving 7 updates/second can
send ~84KB/sec of redundant layout HTML. With this optimization,
layout diffs only occur when layout-relevant assigns actually change.

# `dashboard_layout_keys`

```elixir
@spec dashboard_layout_keys() :: [atom()]
```

Returns the list of assign keys used by the dashboard layout.

Useful for debugging or extending the layout with custom assigns.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
