Blazor Popover Overview

The Blazor Popover component behaves much like a tooltip, as it helps you display additional information in a container that shows on top of the other page content. The major differences between the Popover and the Tooltip components is that the Popover has built-in support for action buttons and provides more configuration options about its animation and placement on the screen. This article explains how to start using the component and describes its features.

Telerik UI for Blazor Ninja image

The Popover component is part of Telerik UI for Blazor, a professional grade UI library with 110+ native components for building modern and feature-rich applications. To try it out sign up for a free 30-day trial.

Creating Blazor Popover

  1. Add the <TelerikPopover> tag to a Razor file.
  2. Obtain a @ref of the component.
  3. Add the content to the <PopoverContent> child tag.
  4. Use the Show method to display the <TelerikPopover>.
  5. (optional) Add a title inside a <PopoverHeader> tag. HTML markup and child components are supported, too.

Basic configuration of the Telerik Popover for Blazor

<TelerikPopover @ref="@PopoverRef"
                AnchorSelector=".popover-target">
    <PopoverContent>
        I am a Telerik Popover
    </PopoverContent>
    <PopoverActions>
        <TelerikButton OnClick="@(() => PopoverRef.Hide())" Icon="@SvgIcon.X">Close</TelerikButton>
    </PopoverActions>
</TelerikPopover>

<TelerikButton OnClick="@(() => PopoverRef.Show())" Class="popover-target">Show the Popover</TelerikButton>

@code{
    private TelerikPopover PopoverRef { get; set; }
}

Popover Positioning and Collision

Use the available positioning and collision settings to customize how the Popover positions itself and reacts to insufficient space in the viewport. Read more about the Blazor Popover Positioning and Collision...

Popover Animations

Use the available parameters to customize the animation type and its duration. Read more about the Blazor Popover Animations...

Popover Parameters

The Blazor Popover provides parameters to configure the component. Also check the Popover API Reference for a full list of properties.

Parameter Type Description
ActionsLayout PopoverActionsLayoutAlign enum
(Stretch)
The positioning of the elements in the <PopoverActions> child tag. The possible values are Stretch, Start, Center, and End.
AnchorSelector string The CSS selector targeting the element that the Popover uses as an anchor.
AnimationDuration int The duration of the animation in milliseconds. Read more about Popover animations...
AnimationType AnimationType enum
(SlideDown)
The type of animation when the component displays and hides. Read more about Popover animations...
Collision PopoverCollision enum
(Fit)
The behavior of the Popover when it doesn't fit in the viewport. Read more about Popover collision...
Offset double The space between the Popover and its anchor in pixels.
Position PopoverPosition enum
(Top)
The position relative to the target element at which the Popover will be shown. Read more about Popover position...
ShowCallout bool
(true)
Defines if the callout is rendered.
ShowOn PopoverShowEvent enum
(Click)
The browser event that will display the Popover (MouseEnter or Click). When you set the ShowOn parameter to Click, the Popover will hide when the user clicks outside the component. If the parameter's value is MouseEnter, the Popover will hide when the mouse pointer leaves.

Styling and Appearance

The following parameters enable you to customize the appearance of the Blazor Popover:

Parameter Type Description
Class string The custom CSS class to be rendered on the <div> element, which wraps the component ChildContent. Use for styling customizations.
Height string The height of the Popover.
Width string The width of the Popover.

Popover Reference and Methods

To execute Popover methods, obtain a reference to the component instance with @ref.

Method Description
Refresh Use this method to programmatically re-render the Popover.
The Popover is rendered as a child of the TelerikRootComponent, instead of where it is declared. As a result, it doesn't automatically refresh when its content is updated. In such cases, the Refresh method comes in handy to ensure that the Popover content is up-to-date.
Show Use this method to display the Popover.
Hide Use this method to close the Popover.
<TelerikPopover @ref="@PopoverRef"
                AnchorSelector=".popover-target">
    <PopoverContent>
        I am a Telerik Popover
    </PopoverContent>
    <PopoverActions>
        <TelerikButton OnClick="@(() => PopoverRef.Hide())" Icon="@SvgIcon.X">Close</TelerikButton>
    </PopoverActions>
</TelerikPopover>

<TelerikButton OnClick="@(() => PopoverRef.Show())" Class="popover-target">Show the Popover</TelerikButton>

@code{
    private TelerikPopover PopoverRef { get; set; }
}

Next Steps

See Also

In this article