# Adding Modality to the Window

## Environment

<table>
	<tr>
		<td>Product</td>
		<td>Progress® Kendo UI® for Angular Window</td>
	</tr>
</table>

## Description

How can I make the Kendo UI for Angular Window modal, just like the Dialog?

## Solution

The Window component does not provide built-in modality like the Dialog component. You can implement modality using one of the following approaches.

### Simulating Modality

To simulate modality, add a `div` element with the `k-overlay` CSS class to your component template. Use the `@if` control flow to show the overlay only when the Window is open.

```html
@if (opened) {
  <div class="k-overlay"></div>
}
<kendo-window [title]="'Window Title'" [(opened)]="opened">
  
</kendo-window>
```

The `k-overlay` class creates a semi-transparent backdrop that prevents interaction with elements behind the Window. The `opened` property controls both the Window visibility and the overlay display.

The following example demonstrates the complete implementation.

[Demo Source](https://demos.telerik.com/kendo-angular-ui/demos/knowledge-base/window-modality/basic/source.txt)

### Using the Angular Service

Add modality to a Window when you open it through the [`WindowService`](https://www.telerik.com/kendo-angular-ui-develop/components/dialogs/window/service). Manually add the overlay element to the DOM when you open the Window programmatically.

Use this approach to open modal Windows dynamically from your component logic rather than declaratively in templates.

[Demo Source](https://demos.telerik.com/kendo-angular-ui/demos/knowledge-base/window-modality/service/source.txt)

### Using a Service Wrapper

Create a custom service that wraps the [`WindowService`](https://www.telerik.com/kendo-angular-ui-develop/components/dialogs/window/service) to handle overlay creation and removal automatically. The service extends the default `WindowService` functionality to include modal behavior.

```ts
 public openServiceWindow(): void {
    this.serviceWindowRef = this.modalWindowService.open({
      title: 'Service Window with Modal',
      ...
      modal: true, // Custom property for modal behavior
    });
  }
```

This approach centralizes the modal logic in a single service and makes it reusable across your application. Any component can inject this service and open modal Windows without repeating the overlay management code.

[Demo Source](https://demos.telerik.com/kendo-angular-ui/demos/knowledge-base/window-modality/service-wrapper/source.txt)

### Using a Directive

Create a reusable directive that automatically manages the overlay. The directive adds the overlay when the Window opens and removes it when the Window closes.

Apply the custom `modalOverlay` attribute to the `kendo-window` element to activate this behavior:

```html
<kendo-window
    [title]="'Window Title'"
    [(opened)]="opened"
    [modalOverlay]="opened">
  
</kendo-window>
```

This approach encapsulates the modal logic in a directive, making it easy to reuse across multiple Window instances.

[Demo Source](https://demos.telerik.com/kendo-angular-ui/demos/knowledge-base/window-modality/directive/source.txt)

## Suggested Links

* [API Reference of the Window](https://www.telerik.com/kendo-angular-ui-develop/components/dialogs/api/windowcomponent)
* [API Reference of the WindowService](https://www.telerik.com/kendo-angular-ui-develop/components/dialogs/window/service)
