# Popup Appearance

The Kendo UI for Angular ContextMenu provides flexible options to customize the appearance and behavior of the popup element that appears when opening the ContextMenu.

<Row>
  <Column count={[24,24,8]} style={{marginBottom: "1rem"}}>
    <Component className="tile" href="#popup-settings">
      <ComponentTitle>Popup Settings</ComponentTitle>
      <ComponentDescription style={{padding: "0 10px 10px 10px"}}>Apply custom CSS classes and set margins on the popup using the <code>popupSettings</code> property.</ComponentDescription>
    </Component>
  </Column>
  <Column count={[24,24,8]} style={{marginBottom: "1rem"}}>
    <Component className="tile" href="#animation">
      <ComponentTitle>Animation</ComponentTitle>
      <ComponentDescription style={{padding: "0 10px 10px 10px"}}>Configure the type and duration of the animation when the popup opens and closes.</ComponentDescription>
    </Component>
  </Column>
  <Column count={[24,24,8]} style={{marginBottom: "1rem"}}>
    <Component className="tile" href="#alignment-and-collision">
      <ComponentTitle>Alignment and Collision</ComponentTitle>
      <ComponentDescription style={{padding: "0 10px 10px 10px"}}>Control the popup and anchor alignment and configure collision behavior.</ComponentDescription>
    </Component>
  </Column>
</Row>

The following example demonstrates how to customize the ContextMenu popup appearance by configuring alignment, collision behavior, animation settings, and applying custom CSS classes.

[Demo Source](https://demos.telerik.com/kendo-angular-ui/demos/menus/context-menu/popup-appearance/source.txt)

## Popup Settings

Use the [`popupSettings`](https://www.telerik.com/kendo-angular-ui-develop/components/menus/api/contextmenucomponent#popupsettings) property to customize the styling and spacing of the popup. The property accepts a [`PopupSettings`](https://www.telerik.com/kendo-angular-ui-develop/components/menus/api/popupsettings) object with the following options:

* [`popupClass`](https://www.telerik.com/kendo-angular-ui-develop/components/menus/api/popupsettings#popupclass)—Specifies the CSS classes to apply to the popup container. Use this option to apply custom styles like borders, shadows, or background colors.
* [`margin`](https://www.telerik.com/kendo-angular-ui-develop/components/menus/api/popupsettings#margin)—Sets the horizontal and vertical margin value in pixels, adding space between the popup and the anchor element.

```HTML
<kendo-contextmenu [target]="target" [items]="items" [popupSettings]="popupSettings">
</kendo-contextmenu>
```

```TS
public popupSettings: PopupSettings = {
    popupClass: 'custom-popup',
    margin: { horizontal: 0, vertical: 4 }
};
```

```CSS
.custom-popup {
    border-left: 3px solid #ff6358;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}
```

## Animation

The ContextMenu provides two properties to control animations:

* [`popupAnimate`](https://www.telerik.com/kendo-angular-ui-develop/components/menus/api/contextmenucomponent#popupanimate)—Controls the animation of the main ContextMenu popup.
* [`animate`](https://www.telerik.com/kendo-angular-ui-develop/components/menus/api/contextmenucomponent#animate)—Controls the animation of submenu popups when child items are opened.

### Main Popup Animation

Use the `popupAnimate` property to configure how the main ContextMenu popup animates when opening. Set it to `false` to disable animations, or provide a [`PopupAnimation`](https://www.telerik.com/kendo-angular-ui-develop/components/popup/api/popupanimation) object to customize the animation behavior.

The `PopupAnimation` interface provides the following options:

* [`type`](https://www.telerik.com/kendo-angular-ui-develop/components/popup/api/popupanimation#type)—The animation type. The default value is `slide`.
* [`duration`](https://www.telerik.com/kendo-angular-ui-develop/components/popup/api/popupanimation#duration)—The animation duration in milliseconds. The default value is `100`.
* [`direction`](https://www.telerik.com/kendo-angular-ui-develop/components/popup/api/popupanimation#direction)—The animation direction. Applicable if the type is `slide` or `expand`. The default value is `down`.

```HTML
<kendo-contextmenu [popupAnimate]="popupAnimationSettings"></kendo-contextmenu>
```

```TS
public popupAnimationSettings: PopupAnimation = {
    type: 'expand',
    duration: 200,
    direction: 'down'
};
```

### Submenu Popup Animation

Use the `animate` property to configure how submenu popups animate when opening. Set it to `false` to disable submenu animations, or provide a [`MenuAnimation`](https://www.telerik.com/kendo-angular-ui-develop/components/menus/api/menuanimation) object to customize the animation behavior.

The `MenuAnimation` interface provides the following options:

* [`type`](https://www.telerik.com/kendo-angular-ui-develop/components/menus/api/menuanimation#type)—The animation type. The default value is `slide`.
* [`duration`](https://www.telerik.com/kendo-angular-ui-develop/components/menus/api/menuanimation#duration)—The animation duration in milliseconds. The default value is `100`.

```HTML
<kendo-contextmenu [animate]="submenuAnimationSettings"></kendo-contextmenu>
```

```TS
public submenuAnimationSettings: MenuAnimation = {
    type: 'expand',
    duration: 200
};
```

## Alignment and Collision

The ContextMenu provides properties to control how the popup aligns with the anchor element and how it behaves when it reaches viewport boundaries.

### Popup Alignment

Use the [`popupAlign`](https://www.telerik.com/kendo-angular-ui-develop/components/menus/api/contextmenucomponent#popupalign) property to specify the pivot point of the popup. This determines which point of the popup aligns with the anchor point.

```ts
public popupAlign: Align = { horizontal: 'left', vertical: 'top' };
```

### Anchor Alignment

Use the [`anchorAlign`](https://www.telerik.com/kendo-angular-ui-develop/components/menus/api/contextmenucomponent#anchoralign) property to specify the pivot point of the anchor element. This property is applicable when [`alignToAnchor`](https://www.telerik.com/kendo-angular-ui-develop/components/menus/api/contextmenucomponent#aligntoanchor) is set to `true`.

```ts
public anchorAlign: Align = { horizontal: 'left', vertical: 'bottom' };
```

### Collision Behavior

Use the [`collision`](https://www.telerik.com/kendo-angular-ui-develop/components/menus/api/contextmenucomponent#collision) property to configure how the popup behaves when it collides with the viewport boundaries. The property accepts a [`Collision`](https://www.telerik.com/kendo-angular-ui-develop/components/popup/api/collision) object that controls both horizontal and vertical collision behavior.

The available collision options are:

* `fit`—Moves the popup horizontally or vertically until it fits within the viewport.
* `flip`—Flips the popup to the opposite side of the anchor if it does not fit.

```ts
public collision: Collision = { horizontal: 'fit', vertical: 'flip' };
```

## Popup Container

By default, the ContextMenu popup renders at the root level of the application. Use the [`appendTo`](https://www.telerik.com/kendo-angular-ui-develop/components/menus/api/contextmenucomponent#appendto) property of the ContextMenu component to specify a different container for the popup. This option is useful when you need the popup to render in a specific location in the DOM.

```HTML
<kendo-contextmenu [target]="target" [items]="items" [appendTo]="popupContainer"></kendo-contextmenu>
<div #popupContainer></div>
```

```TS
@ViewChild('popupContainer', { read: ViewContainerRef })
public popupContainer: ViewContainerRef;
```

## Suggested Links

* [API Reference of the ContextMenu](https://www.telerik.com/kendo-angular-ui-develop/components/menus/api/contextmenucomponent)
* [API Reference of PopupSettings](https://www.telerik.com/kendo-angular-ui-develop/components/menus/api/popupsettings)
* [ContextMenu Appearance](https://www.telerik.com/kendo-angular-ui-develop/components/menus/contextmenu/appearance)
