# RadzenPopup Class

A component that displays its child content in a floating overlay anchored to a target element. Supports smart positioning, optional width syncing with the target, lazy rendering, and close-on-outside-click behavior.

Namespace: [Radzen.Blazor](https://blazor.radzen.com/docs/api/Radzen.Blazor.md)

Assembly: Radzen.Blazor.dll

## Inheritance

- Object
- ComponentBase
- [RadzenComponent](https://blazor.radzen.com/docs/api/Radzen.RadzenComponent.md)
- RadzenPopup

## Implements

- IComponent
- IHandleEvent
- IHandleAfterRender

## Syntax

```csharp
public class RadzenPopup : RadzenComponent, IComponent, IHandleEvent, IHandleAfterRender
```

## Examples

Toggle a popup relative to a button:

```razor
<RadzenButton Text="Open" Click="@(args => popup.ToggleAsync(button.Element))" @ref="button" />
<RadzenPopup @ref="popup" Lazy="true">
    Popup content
</RadzenPopup>
@code {
    RadzenButton button;
    RadzenPopup popup;
}
```

## Constructors

| Constructor | Description |
|-------------|-------------|
| `public RadzenPopup()` | A component that displays its child content in a floating overlay anchored to a target element. Supports smart positioning, optional width syncing with the target, lazy rendering, and close-on-outside-click behavior. |

## Properties

| Property | Type | Description |
|------|------|-------------|
| AutoFocusFirstElement | `bool` | Specifies whether the first element in the popup should be automatically focused. |
| ChildContent | `RenderFragment` | Gets or sets the content to be rendered inside the popup. |
| Close | `EventCallback` | Event callback triggered when the popup is closed. |
| CloseOnClickOutside | `bool` | Specifies whether the popup should close when clicking outside of it. |
| IsOpen | `bool` | Gets a value indicating whether the popup is currently open. |
| Lazy | `bool` | Determines whether the popup content is rendered only when open. |
| Open | `EventCallback` | Event callback triggered when the popup is opened. |
| PreventDefault | `bool` | Specifies whether to prevent the default action on mouse down. |

## Methods

| Method | Returns | Description |
|------|---------|-------------|
| `BuildRenderTree(Rendering.RenderTreeBuilder __builder)` | `void` |  |
| `CloseAsync()` | `Task` | Closes the popup. |
| `CloseAsync(ElementReference target)` | `Task` | Closes the popup. |
| `Dispose()` | `void` |  |
| `OnBecameInvisible()` | `void` |  |
| `OnClose()` | `Task` | Invoked from JavaScript to close the popup. |
| `ToggleAsync(ElementReference target, bool disableSmartPosition, bool syncWidth)` | `Task` | Toggles the popup open or closed. Parameters: `target`: The target element reference. `disableSmartPosition`: Whether to disable smart positioning. `syncWidth`: Whether to synchronize the width of the popup with the target element. |

## Inherited Members

- From [RadzenComponent](https://blazor.radzen.com/docs/api/Radzen.RadzenComponent.md): AddContextMenu, Attributes, ContextMenu, Culture, CurrentStyle, Debounce, DefaultCulture, DefaultUICulture, Element, GetComponentCssClass, GetCssClass, GetId, GetIdAttribute, IsJSRuntimeAvailable, JSRuntime, Localize, MouseEnter, MouseLeave, OnAfterRenderAsync, OnContextMenu, OnInitialized, OnMouseEnter, OnMouseLeave, RaiseContextMenu, RaiseMouseEnter, RaiseMouseLeave, Reference, SetParametersAsync, Style, UICulture, UniqueID, Visible
- From ComponentBase: Assets, AssignedRenderMode, DispatchExceptionAsync, InvokeAsync, OnAfterRender, OnInitializedAsync, OnParametersSet, OnParametersSetAsync, RendererInfo, ShouldRender, StateHasChanged

