Popover
A non-modal panel anchored to a button.
On this page
Examples
Bound open state
State: closed
Razor
<div class="flex flex-wrap items-center gap-4">
<KlyPopover @bind-Open="_open" Placement="KlyPlacement.BottomStart">
<ChildContent><KlyButton Label="Open bound" Variant="ButtonVariant.Outline" data-testid="bound-trigger" /></ChildContent>
<Content>
<div class="flex w-64 flex-col items-start gap-2 p-4" data-testid="bound-panel">
<p class="text-sm">Escape or a click outside closes me.</p>
<KlyButton Label="Close" Size="KlySize.Sm" OnClick="() => _open = false" data-testid="bound-close" />
</div>
</Content>
</KlyPopover>
<p class="text-sm text-(--klyroo-text-muted)" data-testid="bound-state">State: @(_open ? "open" : "closed")</p>
</div>
@code {
private bool _open;
}Unbound
Opens and closes without leaving the browser.
Razor
<KlyPopover Placement="KlyPlacement.Right">
<ChildContent><KlyButton Label="Open unbound" Color="KlyColor.Neutral" Variant="ButtonVariant.Subtle" data-testid="unbound-trigger" /></ChildContent>
<Content>
<div class="flex w-64 flex-col gap-2 p-4" data-testid="unbound-panel">
<KlyFormField Label="Name" Id="pg-name">
<KlyInput data-testid="unbound-input" />
</KlyFormField>
</div>
</Content>
</KlyPopover>API
KlyPopover
Non-modal floating panel anchored to a trigger. ChildContent is the trigger: its first button (or focusable element) opens and closes the panel. Opening, closing, Escape, light dismiss, positioning and focus run in the browser, so they cost no round trip in Server mode and work in static server rendering once blazor.web.js has loaded.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
AriaLabel |
string |
Accessible name of the panel. Defaults to the trigger's text. | |
Class |
string |
Classes added to the root element, merged last so they win over the theme. | |
Offset |
int |
8 |
Distance between trigger and panel, in pixels. |
Open (@bind-Open) |
bool |
false |
Open state. Use @bind-Open : the browser can close the panel on its own (Escape, click outside). |
Placement |
KlyPlacement |
KlyPlacement. |
Where the panel sits against the trigger. Defaults to Bottom . Values: Top, TopStart, TopEnd, Right, RightStart, RightEnd, Bottom, BottomStart, BottomEnd, Left, LeftStart, LeftEnd. |
Role |
string |
"dialog" |
Role of the panel. Defaults to dialog . Null renders a plain panel, a disclosure as in the WAI-ARIA navigation pattern: the trigger then only reports aria-expanded and aria-controls , and AriaLabel is not rendered because a role-less element cannot carry a name. |
Ui |
PopoverUi |
Per-instance class overrides of the slots of the popover, see PopoverUi . |
Slots
| Name | Type | Description |
|---|---|---|
Content |
RenderFragment |
The panel content. |
ChildContent |
RenderFragment |
The trigger. |
Ui slots
Ui takes a PopoverUi with one class string per slot, merged after the theme.
| Slot | Styles |
|---|---|
Content |
Classes merged into the content slot of KlyPopover , after the theme and the app configuration. |