---
title: "Active Overlay"
framework: vue
version: "36.1.0"
---

# Active Overlay

Applications can display an overlay on demand regardless of grid state. This is achieved by providing an active overlay which can be one of the provided overlays or be a custom overlay component.

#### Active Overlay (Component Class)

```ts
import { createApp, defineComponent, ref, shallowRef } from "vue";

import type { ColDef, GridApi, GridReadyEvent } from "ag-grid-community";
import {
  ClientSideRowModelModule,
  ModuleRegistry,
  enableDevValidations,
} from "ag-grid-community";
import { AgGridVue } from "ag-grid-vue3";

import { CustomOverlay } from "./customOverlay";
import "./styles.css";

// Enable extended validations only for development
if (process.env.NODE_ENV !== "production") {
  enableDevValidations();
}

ModuleRegistry.registerModules([ClientSideRowModelModule]);

interface IAthlete {
  athlete: string;
  country: string;
}

const VueExample = defineComponent({
  template: `<div class="example-wrapper">
            <div class="button-row">
                <button v-on:click="showActiveOverlay()">Show custom overlay</button>
                <button v-on:click="clearActiveOverlay()">Hide custom overlay</button>
                <button v-on:click="incrementParam()">Increment Param</button>
            </div>
            <ag-grid-vue
                class="grid-wrapper"
                :columnDefs="columnDefs"
                :rowData="rowData"
                :activeOverlay="activeOverlay"
                :activeOverlayParams="activeOverlayParams"
            />
        </div>`,
  components: {
    "ag-grid-vue": AgGridVue,
  },
  setup(props) {
    const columnDefs = ref<ColDef[]>([
      { field: "athlete", flex: 1 },
      { field: "country", flex: 1 },
    ]);
    const rowData = ref<IAthlete[] | null>([
      { athlete: "Michael Phelps", country: "United States" },
      { athlete: "Natalie Coughlin", country: "United States" },
      { athlete: "Aleksey Nemov", country: "Russia" },
      { athlete: "Alicia Coutts", country: "Australia" },
    ]);
    const activeOverlay = shallowRef<any>(CustomOverlay);
    const activeOverlayParams = ref<{ count: number }>({ count: 1 });

    function showActiveOverlay() {
      activeOverlay.value = CustomOverlay;
    }
    function clearActiveOverlay() {
      activeOverlay.value = undefined;
    }
    function incrementParam() {
      activeOverlayParams.value.count++;
    }

    return {
      columnDefs,
      rowData,
      activeOverlay,
      activeOverlayParams,
      showActiveOverlay,
      clearActiveOverlay,
      incrementParam,
    };
  },
});

const app = createApp(VueExample);
app.mount("#app");
```

[Live example: Active Overlay (Component Class)](https://www.ag-grid.com/examples/overlays-active/active-overlay-component/vue3)

## Display an Active Overlay

To display an overlay on demand set the `activeOverlay` / `activeOverlayParams` grid option. To clear the overlay set `activeOverlay = undefined`.

| Property | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `activeOverlay` | `any` |  |  | Display an overlay on demand. If provided takes precedence over the grid provided overlays. - name of a provided overlay, i.e `agLoadingOverlay`, `agNoRowsOverlay`, `agNoMatchingRowsOverlay`, `agExportingOverlay` - component class/function. - key of a custom component registered in the `components` map. - `undefined` to clear. |
| `activeOverlayParams` | `any` |  |  | Custom parameters to be supplied to the `activeOverlay` component in addition to `IOverlayParams`. Updating the params will trigger a refresh of the active overlay. |

Any valid Vue component can be used, however the optional `IOverlay` interface exposes lifecycle hooks that receive `IOverlayParams`.

```ts

interface IOverlay&lt;TData = any, TContext = any, TParams extends Readonly<<span/>IOverlayParams<<span/>TData, TContext>> = IOverlayParams<<span/>TData, TContext>&gt; {
  // Gets called when the `overlayComponentParams` grid option is updated
  refresh?(params: TParams): void;

}
```

The example below demonstrates using the grid provided overlays as an active overlay. Note the following:

- activeOverlays take precedence over the provided loading overlay.
- activeOverlay can be displayed no matter what the grid state, i.e showing the no-rows overlay even when there are rows.
- StatusOverlay is registered in the [components](https://www.ag-grid.com/vue-data-grid/components/#registering-custom-components) map and shown by setting `activateOverlay = "statusOverlay"` to the key used.

#### Active Overlay Switcher

```ts
import { createApp, defineComponent, ref } from "vue";

import type { ColDef } from "ag-grid-community";
import {
  ClientSideRowModelModule,
  ModuleRegistry,
  enableDevValidations,
} from "ag-grid-community";
import { AgGridVue } from "ag-grid-vue3";

import { StatusOverlay } from "./statusOverlay";
import "./styles.css";

// Enable extended validations only for development
if (process.env.NODE_ENV !== "production") {
  enableDevValidations();
}

ModuleRegistry.registerModules([ClientSideRowModelModule]);

interface Athlete {
  athlete: string;
  country: string;
}

const columnDefs: ColDef<Athlete>[] = [
  { field: "athlete", flex: 1 },
  { field: "country", flex: 1 },
];

const rowData: Athlete[] = [
  { athlete: "Michael Phelps", country: "United States" },
  { athlete: "Alicia Coutts", country: "Australia" },
];

const VueExample = defineComponent({
  components: {
    "ag-grid-vue": AgGridVue,
  },
  template: `
        <div class="example-wrapper">
            <div class="button-row">
                <label class="toggle loading-toggle">
                    <input type="checkbox" :checked="loading === true" @change="onLoadingToggle" /> Loading
                </label>
                <button type="button" @click="showNoRowsOverlay">activeOverlay = agNoRowsOverlay</button>
                <button type="button" @click="showCustomOverlay">activeOverlay = CustomOverlay</button>
                <button type="button" @click="clearOverlay">Hide activeOverlay</button>
            </div>
            <ag-grid-vue
                class="grid-wrapper"
                :columnDefs="columnDefs"
                :rowData="rowData"
                :components="components"
                :loading="loading"
                :activeOverlay="activeOverlay"
            />
        </div>
    `,
  setup() {
    const activeOverlay = ref<string | undefined>();
    const loading = ref<boolean | undefined>(undefined);
    const components = { statusOverlay: StatusOverlay };

    const showNoRowsOverlay = () => {
      activeOverlay.value = "agNoRowsOverlay";
    };

    const showCustomOverlay = () => {
      activeOverlay.value = "statusOverlay";
    };

    const clearOverlay = () => {
      activeOverlay.value = undefined;
    };

    const onLoadingToggle = (event: Event) => {
      const checked = (event.target as HTMLInputElement).checked;
      loading.value = checked ? true : undefined;
    };

    return {
      columnDefs,
      rowData,
      components,
      activeOverlay,
      loading,
      onLoadingToggle,
      showNoRowsOverlay,
      showCustomOverlay,
      clearOverlay,
    };
  },
});

createApp(VueExample).mount("#app");
```

[Live example: Active Overlay Switcher](https://www.ag-grid.com/examples/overlays-active/active-overlay-switcher/vue3)
