---
title: Building Panels When They Are Needed
description: Which overlays can keep their panel out of the page until it is first needed, when each one builds it, and how to set that for a whole application.
visibility: guest
draft: false
related:
  - /components/popover
  - /components/dropdown
  - /components/tooltip
  - /components/combobox
  - /components/modal
---

# Building Panels When They Are Needed

An overlay draws its panel in a `<template>` that Alpine moves to the end of the page as it starts, so every panel on a page starts with the page, whether its overlay ever opens or not. A page with a menu in every row, a tooltip on every icon or a confirmation for every record starts panels nobody looks at.

With `lazy`, an overlay keeps its panel in a `<template>` the browser does not render, and builds it the first time it is needed. Once built, the panel stays when the overlay closes again, and it opens, takes the focus and closes as a panel built with the page does. `lazy` is off by default.

## The Overlays That Take It

| Overlay | Where `lazy` goes | Built when | Configuration key |
| --- | --- | --- | --- |
| [Popover](/components/popover#building-the-panel-when-it-is-needed) | `<x-wirekit::popover>` | the pointer or the focus reaches the trigger, or the popover opens | `components.popover.lazy` |
| [Dropdown](/components/dropdown#building-the-panel-when-it-is-needed) | `<x-wirekit::dropdown>`, in both forms | the pointer or the focus reaches the trigger, or the menu opens | `components.dropdown.lazy` |
| [Notification center](/components/notification-center#building-the-panel-when-it-is-needed) | `<x-wirekit::notification-center>` | the pointer or the focus reaches the bell, or the panel opens | `components.notification-center.lazy` |
| [Tooltip](/components/tooltip#building-the-panel-when-it-is-needed) | `<x-wirekit::tooltip>` | the tooltip first shows | `components.tooltip.lazy` |
| [Text with `truncate="tooltip"`](/components/text#truncation-with-a-tooltip) | the configuration only | the tooltip first shows on a cut text | `components.tooltip.lazy` |
| [Combobox](/components/combobox#building-the-list-when-it-is-needed) | `<x-wirekit::combobox>` | the pointer or the focus reaches the field, or the list opens | `components.combobox.lazy` |
| [Multi-select](/components/multi-select#building-the-list-when-it-is-needed) | `<x-wirekit::multi-select>`, in its dropdown layout | the pointer or the focus reaches the field, or the list opens | `components.multi-select.lazy` |
| [Color picker](/components/color-picker#building-the-panel-when-it-is-needed) | `<x-wirekit::color-picker>`, in its popover mode | the pointer or the focus reaches the picker, or the panel opens | `components.color-picker.lazy` |
| [Context menu](/components/context-menu#building-the-menu-when-it-is-needed) | `<x-wirekit::context-menu>` | the menu first opens | `components.context-menu.lazy` |
| [Menubar](/components/menubar#building-the-menus-when-they-are-needed) | `<x-wirekit::menubar>`, for each of its menus | a menu first opens | `components.menubar.lazy` |
| [Navigation menu](/components/navigation-menu#building-the-panels-when-they-are-needed) | `<x-wirekit::navigation-menu>`, for each of its panels | a panel first opens | `components.navigation-menu.lazy` |
| [Hover card](/components/hover-card#building-the-card-when-it-is-needed) | `<x-wirekit::hover-card>` | the card first shows | `components.hover-card.lazy` |
| [Modal](/components/modal#building-the-panel-when-it-is-needed) | `<x-wirekit::modal>` | the modal first opens | `components.modal.lazy` |
| [Drawer](/components/drawer#building-the-panel-when-it-is-needed) | `<x-wirekit::drawer>` | the drawer first opens | `components.drawer.lazy` |
| [Alert dialog](/components/alert-dialog#building-the-panel-when-it-is-needed) | `<x-wirekit::alert-dialog>` | the dialog first opens | `components.alert-dialog.lazy` |
| [Command palette](/components/command-palette#building-the-palette-when-it-is-needed) | `<x-wirekit::command-palette>` | the palette first opens | `components.command-palette.lazy` |
| [Tour](/components/tour#building-the-tour-when-it-starts) | `<x-wirekit::tour>` | the tour first starts | `components.tour.lazy` |
| [Lightbox](/components/lightbox#building-the-viewer-when-it-is-needed) | `<x-wirekit::lightbox>` | the viewer first opens | `components.lightbox.lazy` |
| [Filter builder](/components/filter-builder#building-the-panel-when-it-is-needed) | `<x-wirekit::filter-builder>` | the panel first opens, to add a filter or to edit one | `components.filter-builder.lazy` |
| [Date picker](/components/date-picker#building-the-dialog-when-it-is-needed) | `<x-wirekit::date-picker>`, in popover mode | the dialog first opens | `components.date-picker.lazy` |
| [Time picker](/components/time-picker#building-the-dialog-when-it-is-needed) | `<x-wirekit::time-picker>`, in popover mode with a list of times | the dialog first opens | `components.time-picker.lazy` |
| [Datetime picker](/components/datetime-picker#building-the-dialog-when-it-is-needed) | `<x-wirekit::datetime-picker>` | the dialog first opens | `components.datetime-picker.lazy` |

A [select](/components/select#building-the-list-when-it-is-needed) keeps its options in a template the same way, with `lazy`, until the field is first used.

## Setting It for the Whole Application

Each overlay takes its default from its key under `components` in `config/wirekit.php`:

```php
// config/wirekit.php
'components' => [
    'popover' => ['lazy' => true],
    'dropdown' => ['lazy' => true],
    'tooltip' => ['lazy' => true],
],
```

The prop on one overlay wins over the configuration: `:lazy="false"` builds that overlay's panel with the page.

## What a Lazy Panel Changes

- Until an overlay is built, its panel is not part of the page. A script that looks for something inside it, a browser test that reads it before the overlay opens, and a crawler that follows its links find nothing there. Open the overlay first, or leave `lazy` off for an overlay whose panel something has to find while it is closed.
- A trigger that names its panel with `aria-controls` names it from the moment the panel is built, and names no element before.
- A tooltip describes its trigger from the start all the same: its words stand hidden beside the trigger.
- Inside a Livewire component, a render keeps a panel the overlay has built and updates it like any other part of the page, and an overlay that waits takes the new content for the moment it builds.
- `lazy` on one overlay reaches no overlay inside it: a dropdown in a lazy popover builds its own panel as its own `lazy` says.
