# Popover Configuration

The Popover enables you to display rich content that appears on user interaction with a particular element. It comes with a highly customizable functionality in terms of the targeted elements, content, templates, opening and closing mechanics, and more.

The following example demonstrates a basic popover in action

[Demo Source](https://demos.telerik.com/kendo-angular-ui/demos/tooltips/popover/configuration/source.txt)

## Setup

To define the contents of the [`Popover`](https://www.telerik.com/kendo-angular-ui-develop/components/tooltips/api/popovercomponent) add the `<kendo-popover>` tag on the page. The popover content is divided in 3 main sections, each of which is optional. Those are:

* `title`—Represents the header section of the popover. To configure the title, either pass a string to the [`title`](https://www.telerik.com/kendo-angular-ui-develop/components/tooltips/api/popovercomponent#title) configuration option or define a [`title template`](https://www.telerik.com/kendo-angular-ui-develop/components/tooltips/popover/templates).
* `body`—Represents the main content section of the popover. To configure the body, either pass a string to the [`body`](https://www.telerik.com/kendo-angular-ui-develop/components/tooltips/api/popovercomponent#body) configuration option or define a [`body template`](https://www.telerik.com/kendo-angular-ui-develop/components/tooltips/popover/templates).
* `actions`—Represents an action buttons section that will be displayed below the `body`. To configure the popover actions, define an [`actions template`](https://www.telerik.com/kendo-angular-ui-develop/components/tooltips/popover/templates).

```html
<kendo-popover title="Header content" body="Main content">
</kendo-popover>
```

The `<kendo-popover>` tag is only used to define the contents of the popover. In order to display the popover on the page, you should specify the anchor elements that it will be attached to. There are two main ways to display the Popover, depending on whether it should be linked to a single or multiple elements. Both are described in details in the sections below:

* [Popover Anchor](https://www.telerik.com/kendo-angular-ui-develop/components/tooltips/popover/configuration#popover-anchor)
* [Popover Container](https://www.telerik.com/kendo-angular-ui-develop/components/tooltips/popover/configuration#popover-container)

## Popover Anchor

The popover enables you to display it in relation to a single DOM element. To achieve this:

1. Apply the [`kendoPopoverAnchor`](https://www.telerik.com/kendo-angular-ui-develop/components/tooltips/api/popoveranchordirective) directive to the element that should display the popover.

```html
<button kendoPopoverAnchor>Show Popover</button>
```

2. Pass a popover instance to the [`popover`](https://www.telerik.com/kendo-angular-ui-develop/components/tooltips/api/popoveranchordirective#popover) input of the [`kendoPopoverAnchor`](https://www.telerik.com/kendo-angular-ui-develop/components/tooltips/api/popoveranchordirective) directive.

```html
<button kendoPopoverAnchor [popover]="myPopover">Show Popover</button>

<kendo-popover #myPopover title="Header content" body="Main content">
</kendo-popover>
```

3. Optionally configure the type of user interaction, on which the popover should be displayed by setting the [`showOn`](https://www.telerik.com/kendo-angular-ui-develop/components/tooltips/api/popoveranchordirective#showon) option of the [`kendoPopoverAnchor`](https://www.telerik.com/kendo-angular-ui-develop/components/tooltips/api/popoveranchordirective) directive. By default it will be displayed on `click`.

```html
<button kendoPopoverAnchor [popover]="myPopover" showOn="hover">Show Popover</button>
```

The following example demonstrates how to attach the popover to a single element.

[Demo Source](https://demos.telerik.com/kendo-angular-ui/demos/tooltips/popover/anchor/source.txt)

## Popover Container

The Popover enables you to display it in relation to multiple DOM elements. This approach is useful for scenarios in which the same popover layout should be reused on multiple occasions. To achieve this:

1. Apply the [`kendoPopoverContainer`](https://www.telerik.com/kendo-angular-ui-develop/components/tooltips/api/popovercontainerdirective) directive to the most outer wrapping element which will hold the popover anchors.

```html
<div kendoPopoverContainer></div>
```

2. Set the [`filter`](https://www.telerik.com/kendo-angular-ui-develop/components/tooltips/api/popovercontainerdirective#filter) option of the [`kendoPopoverContainer`](https://www.telerik.com/kendo-angular-ui-develop/components/tooltips/api/popovercontainerdirective) directive. It is used to determine the child elements, which will serve as popover anchors. The `filter` option accepts a string value, representing any valid query selector.

```html
<div kendoPopoverContainer filter=".has-popover">
    <button class="has-popover">Show Popover</button>
    <button>Button Without Popover</button>
    <button class="has-popover">Show Popover</button>
</div>
```

3. Pass a popover instance to the [`popover`](https://www.telerik.com/kendo-angular-ui-develop/components/tooltips/api/popovercontainerdirective#popover) input of the [`kendoPopoverContainer`](https://www.telerik.com/kendo-angular-ui-develop/components/tooltips/api/popovercontainerdirective) directive.

```html
<div kendoPopoverContainer filter=".has-popover" [popover]="myPopover">
    <button class="has-popover">Show Popover</button>
    <button>Button Without Popover</button>
    <button class="has-popover">Show Popover</button>
</div>

<kendo-popover #myPopover title="Header content" body="Main content">
</kendo-popover>
```

4. Optionally configure the type of user interaction, on which the popovers should be displayed by setting the [`showOn`](https://www.telerik.com/kendo-angular-ui-develop/components/tooltips/api/popovercontainerdirective#showon) option of the [`kendoPopoverContainer`](https://www.telerik.com/kendo-angular-ui-develop/components/tooltips/api/popovercontainerdirective) directive. By default they will be displayed on `click`.

```html
<div kendoPopoverContainer filter=".has-popover" [popover]="myPopover" showOn="focus">
    <button class="has-popover">Show Popover</button>
    <button>Button Without Popover</button>
    <button class="has-popover">Show Popover</button>
</div>
```

> When using the [`kendoPopoverContainer`](https://www.telerik.com/kendo-angular-ui-develop/components/tooltips/api/popovercontainerdirective) directive only one popover at a time will be displayed for the filtered anchor elements.

The following example demonstrates how to attach a popover to a group of elements.

[Demo Source](https://demos.telerik.com/kendo-angular-ui/demos/tooltips/popover/container/source.txt)

## Popover Callback

The [`PopoverAnchor`](https://www.telerik.com/kendo-angular-ui-develop/components/tooltips/api/popoveranchordirective) and [`PopoverContainer`](https://www.telerik.com/kendo-angular-ui-develop/components/tooltips/api/popovercontainerdirective) enable you to apply conditional logic to determine the exact popover instance that should be displayed. To achieve this, pass a [`PopoverFn`](https://www.telerik.com/kendo-angular-ui-develop/components/tooltips/api/popoverfn) callback function to their [`popover`](https://www.telerik.com/kendo-angular-ui-develop/components/tooltips/api/popoveranchordirective#popover) input property. The callback should return the popover instance to be displayed, depending on custom logic.

The following example demonstrates the approach in action.

[Demo Source](https://demos.telerik.com/kendo-angular-ui/demos/tooltips/popover/callback/source.txt)

## Suggested Links

* [API Reference of the Popover](https://www.telerik.com/kendo-angular-ui-develop/components/tooltips/api/popovercomponent)
* [API Reference of the PopoverAnchor](https://www.telerik.com/kendo-angular-ui-develop/components/tooltips/api/popoveranchordirective)
* [API Reference of the PopoverContainer](https://www.telerik.com/kendo-angular-ui-develop/components/tooltips/api/popovercontainerdirective)
