# Custom Tool Panels

Canonical page: https://www.adaptabletools.com/docs/ui-tool-panel-custom-tool-panel

- Custom Tool Panels are Tool Panels provided by Developers
- They are provided in Tool Panel Options
- They are hosted in the Adaptable Tool Panel Component

## Topics on this Page

Every Custom Tool Panel is **defined** in `customToolPanels` and **referenced** in Tool Panel State — see [Wiring up](#wiring-up-custom-tool-panels).

Choose **one** of these content approaches per panel (or use `buttons` for simple actions):

| Content                                           | Property                         | When to use                              |
| ------------------------------------------------- | -------------------------------- | ---------------------------------------- |
| [Adaptable Buttons](#providing-adaptable-buttons) | `buttons`                        | A small set of actions in the panel body |
| [Bespoke content](#providing-bespoke-content)     | `render` or `frameworkComponent` | Custom HTML or framework components      |

Developers are able to provide custom Tool Panels containing bespoke elements.

They are rendered inside the Adaptable ToolPanel Component alongside the Module ToolPanels.

Once defined, Custom ToolPanels can be configured and used in the same way as Module ToolPanels

## Wiring Up Custom Tool Panels

Custom Tool Panels are provided in a 2-step process:

1. The Custom Tool Panel is **defined** in `customToolPanels` in [Tool Panel Options](https://www.adaptabletools.com/docs/technical-reference-tool-panel/index.md)
2. The Custom Tool Panel is **referenced** in [Tool Panel Initial State](https://www.adaptabletools.com/docs/technical-reference-tool-panel/index.md)

### Wiring up a Custom Tool Panel

These are the 2 steps required to provide a Custom Tool Panel in AdapTable.

Create the Custom Tool Panel in `customToolPanels` in [Tool Panel Options](https://www.adaptabletools.com/docs/technical-reference-tool-panel/index.md).

- Add `name` — how the Tool Panel is internally referenced in AdapTable
- Optionally add `title` — the label shown in the Tool Panel header
- Add the content (either AdapTable Buttons or bespoke rendering)

```tsx {3}
const adaptableOptions: AdaptableOptions = {
  toolPanelOptions: {
    customToolPanels: [
      {
        name: 'buttonCustomToolPanel',
        title: 'Quick Actions',
        buttons: [
          // Adaptable Buttons here
        ],
      },
      {
        name: 'bespokeContentCustomToolPanel',
        title: 'Custom Content',
        frameworkComponent: () => {
          // bespoke content; use render if AdapTable Vanilla
        },
      },
    ],
  },
};
```

Reference the Custom Tool Panel in [Tool Panel Initial State](https://www.adaptabletools.com/docs/technical-reference-tool-panel/index.md).

Use the `name` supplied in Tool Panel Options.

Optionally configure the Tool Panel to display as expanded or collapsed.

```ts {3}
initialState: {
  ToolPanel: {
    ToolPanels: [
      {
        Name: 'buttonCustomToolPanel',
        VisibilityMode: 'expanded',
      },
      {
        Name: 'bespokeContentCustomToolPanel',
        VisibilityMode: 'collapsed',
      },
    ],
  },
}
```

## Custom Tool Panel Contents

Custom Tool Panels can contain 2 different sets of content:

1. [Buttons](#providing-adaptable-buttons) — an array of [Adaptable Buttons](https://www.adaptabletools.com/docs/ui-tutorial-displaying-adaptable-buttons/index.md)
2. [Bespoke content](#providing-bespoke-content) — for when more than buttons are required

### Anatomy of a Custom ToolPanel

The [`CustomToolPanel`](https://www.adaptabletools.com/docs/reference/customtoolpanel.md) object is defined as follows:

| Property | Type | Description |
| --- | --- | --- |
| [buttons](https://www.adaptabletools.com/docs/reference/customtoolpanel.md#buttons) | [`AdaptableButton`](https://www.adaptabletools.com/docs/reference/adaptablebutton.md)`<`[`CustomToolPanelButtonContext`](https://www.adaptabletools.com/docs/reference/customtoolpanelbuttoncontext.md)`>[]` | Optional set of buttons to show in the ToolPanel |
| [frameworkComponent](https://www.adaptabletools.com/docs/reference/customtoolpanel.md#frameworkcomponent) | [`AdaptableFrameworkComponent`](https://www.adaptabletools.com/docs/reference/adaptableframeworkcomponent.md) | Framework-specific (Angular, React or Vue) component to be rendered |
| [name](https://www.adaptabletools.com/docs/reference/customtoolpanel.md#name) | `string` | Name of Custom ToolPanel - should be unique |
| [render](https://www.adaptabletools.com/docs/reference/customtoolpanel.md#render) | `(customRenderContext: `[`CustomRenderContext`](https://www.adaptabletools.com/docs/reference/customrendercontext.md)`) => string \| null` | Function to provide bespoke content when using AdapTable Vanilla |
| [title](https://www.adaptabletools.com/docs/reference/customtoolpanel.md#title) | `string` | Title to display in Custom ToolPanel; if undefined, will default to `name` property |

The `name` and `title` properties are self-explanatory.

`buttons` is used if the Custom Tool Panel will only contain [Adaptable Buttons](https://www.adaptabletools.com/docs/ui-tutorial-displaying-adaptable-buttons/index.md).

Otherwise the `render` function (AdapTable Vanilla) or `frameworkComponent` (all Frameworks) needs to be provided.

### Providing AdapTable Buttons

Provide an array of [Adaptable Buttons](https://www.adaptabletools.com/docs/ui-tutorial-displaying-adaptable-buttons/index.md) on the `buttons` property of [`CustomToolPanel`](https://www.adaptabletools.com/docs/reference/customtoolpanel.md).

This workflow is **framework-agnostic** — the same `buttons` configuration works for AdapTable Vanilla, React, Angular, and Vue.

If you only need a few actions in the Tool Panel, prefer `buttons` over bespoke `render` / `frameworkComponent` content

### Providing Custom Tool Panel Buttons

Supply an array of [Adaptable Buttons](https://www.adaptabletools.com/docs/ui-tutorial-displaying-adaptable-buttons/index.md) on the `buttons` property.

Each button's `label`, `onClick`, and other callbacks receive a [`CustomToolPanelButtonContext`](https://www.adaptabletools.com/docs/reference/customtoolpanelbuttoncontext.md) with `adaptableApi`, the current [`Tool Panel State`](https://www.adaptabletools.com/docs/reference/toolpanelstate.md), and the hosting [`CustomToolPanel`](https://www.adaptabletools.com/docs/reference/customtoolpanel.md).

```ts {6}
toolPanelOptions: {
  customToolPanels: [
    {
      name: 'ButtonToolPanel',
      title: 'Quick Actions',
      buttons: [
        {
          label: (button, context) =>
            context.adaptableApi.themeApi.getCurrentTheme() === 'light'
              ? 'Switch to Dark Theme'
              : 'Switch to Light Theme',
          onClick: (button, context) => {
            const themeApi = context.adaptableApi.themeApi;
            themeApi.getCurrentTheme() === 'light'
              ? themeApi.loadDarkTheme()
              : themeApi.loadLightTheme();
          },
          buttonStyle: {tone: 'accent', variant: 'raised'},
        },
        {
          label: 'Open Named Queries',
          onClick: (button, context) => {
            context.adaptableApi.namedQueryApi.openNamedQuerySettingsPanel();
          },
        },
      ],
    },
  ],
},
```

### Configuring Custom Tool Panel Buttons

As with all Adaptable Buttons, each button can be styled and configured with `label`, `icon`, `onClick`, `hidden`, `disabled`, and related properties.

- See [Adaptable Buttons](https://www.adaptabletools.com/docs/ui-tutorial-displaying-adaptable-buttons/index.md) for full configuration details

Button callbacks receive a [`CustomToolPanelButtonContext`](https://www.adaptabletools.com/docs/reference/customtoolpanelbuttoncontext.md):

| Property | Type | Description |
| --- | --- | --- |
| [customToolPanel](https://www.adaptabletools.com/docs/reference/customtoolpanelbuttoncontext.md#customtoolpanel) | [`CustomToolPanel`](https://www.adaptabletools.com/docs/reference/customtoolpanel.md) | The Custom ToolPanel which contains the button |
| [adaptableContext](https://www.adaptabletools.com/docs/reference/customtoolpanelbuttoncontext.md#adaptablecontext) | `any` | Custom application Context provided in `AdaptableOptions.adaptableContext` |

**Example: Custom Tool Panel: Using Buttons**

Providing a Custom Tool Panel with AdapTable Buttons

- This example defines one Custom Tool Panel — `Quick Actions` — containing three AdapTable Buttons:
  - **Switch Theme** — toggles light / dark theme
  - **Open Named Queries** — opens the Named Query settings panel
  - **Show Date** — displays today's date in an alert
- The AdapTable Tool Panel opens on load so the Custom Tool Panel is visible

Demo project (Vanilla); the files without a marker are shown below:

```text
src/
  adaptableOptions.ts
  agGridModules.ts     [template]
  columnDefs.ts        [template]
  gridOptions.ts       [template]
  index.ts             [template]
  onAdaptableReady.ts
  rowData.ts           [template]
  styles.css           [template]
index.html             [template]
package.json           [template]
tsconfig.json          [template]
```

Files marked `[template]` are the same in every demo; see the [demo template](https://www.adaptabletools.com/llms/demo-template.md#vanilla).

**`src/adaptableOptions.ts`**

```ts
import {
  AdaptableButton,
  AdaptableOptions,
  CustomToolPanelButtonContext,
} from '@adaptabletools/adaptable';
import {WebFramework} from './rowData';

export const adaptableOptions: AdaptableOptions<WebFramework> = {
  primaryKey: 'id',
  adaptableId: 'Custom Tool Panel With Buttons',
  toolPanelOptions: {
    customToolPanels: [
      {
        name: 'ButtonToolPanel',
        title: 'Quick Actions',
        buttons: [
          {
            label: (
              button: AdaptableButton<CustomToolPanelButtonContext>,
              context: CustomToolPanelButtonContext
            ) =>
              context.adaptableApi.themeApi.getCurrentTheme() === 'light'
                ? 'Switch to Dark Theme'
                : 'Switch to Light Theme',
            onClick: (
              button: AdaptableButton<CustomToolPanelButtonContext>,
              context: CustomToolPanelButtonContext
            ) => {
              const themeApi = context.adaptableApi.themeApi;
              themeApi.getCurrentTheme() === 'light'
                ? themeApi.loadDarkTheme()
                : themeApi.loadLightTheme();
            },
            buttonStyle: {tone: 'accent', variant: 'raised'},
          },
          {
            label: 'Open Named Queries',
            onClick: (
              button: AdaptableButton<CustomToolPanelButtonContext>,
              context: CustomToolPanelButtonContext
            ) => {
              context.adaptableApi.namedQueryApi.openNamedQuerySettingsPanel();
            },
            buttonStyle: {variant: 'outlined'},
          },
          {
            label: () => 'Show Date',
            onClick: (
              button: AdaptableButton<CustomToolPanelButtonContext>,
              context: CustomToolPanelButtonContext
            ) => {
              context.adaptableApi.alertApi.showAlertInfo(
                'Current Date',
                'Today is: ' + new Date().toLocaleDateString(),
              );
            },
            buttonStyle: {tone: 'info', variant: 'text'},
          },
        ],
      },
    ],
  },
  initialState: {
    ToolPanel: {
      ToolPanels: [
        {
          Name: 'ButtonToolPanel',
          VisibilityMode: 'expanded',
        },
        {
          Name: 'Layout',
          VisibilityMode: 'collapsed',
        },
      ],
    },
    Theme: {CurrentTheme: 'dark'},
    Layout: {
      CurrentLayout: 'Standard Layout',
      Layouts: [
        {
          Name: 'Standard Layout',
          TableColumns: [
            'name',
            'language',
            'github_stars',
            'license',
            'has_projects',
            'has_pages',
            'created_at',
            'has_wiki',
            'updated_at',
            'pushed_at',
            'github_watchers',
            'week_issue_change',
          ],
          AutoSizeColumns: true,
        },
      ],
    },
  },
};
```

**`src/onAdaptableReady.ts`**

```ts
import {AdaptableReadyInfo} from '@adaptabletools/adaptable';

export const onAdaptableReady = ({adaptableApi}: AdaptableReadyInfo) => {
  adaptableApi.toolPanelApi.openAdapTableToolPanel();
};
```

### Providing Bespoke Content

<!-- framework: vanilla -->
### Vanilla

When Adaptable Buttons are not enough, you can provide bespoke HTML in a Custom Tool Panel.

This is done using the `render` property — a function that returns an HTML string (or `null`).

```ts
render?: (context: CustomRenderContext) => string | null;
```

The function receives [`CustomRenderContext`](https://www.adaptabletools.com/docs/reference/customrendercontext.md) defined as follows:

| Property | Type | Description |
| --- | --- | --- |
| [element](https://www.adaptabletools.com/docs/reference/customrendercontext.md#element) | `HTMLDivElement` | Container Div Element |
| [phase](https://www.adaptabletools.com/docs/reference/customrendercontext.md#phase) | `'onMount' \| 'onDestroy'` | Phase of DOM Element lifecycle |
| [adaptableContext](https://www.adaptabletools.com/docs/reference/customrendercontext.md#adaptablecontext) | `any` | Custom application Context provided in `AdaptableOptions.adaptableContext` |

- On `onMount`, return markup for AdapTable to inject into the panel container (`context.element`)
- On `onDestroy`, return `null` and run any teardown (for example removing listeners attached to `context.element`)

### Providing Bespoke Tool Panel Content

Provide a function on the [`CustomToolPanel`](https://www.adaptabletools.com/docs/reference/customtoolpanel.md) that returns the HTML to display.

When [`CustomRenderContext`](https://www.adaptabletools.com/docs/reference/customrendercontext.md) `phase` is `'onMount'`, return your markup.

When `phase` is `'onDestroy'`, return `null`. Use `context.adaptableApi` from [`CustomRenderContext`](https://www.adaptabletools.com/docs/reference/customrendercontext.md) if the panel needs to call AdapTable APIs.

```ts [[1, 6, "render"], [2, 7, "onMount"], [3, 10, "return null"]]
toolPanelOptions: {
  customToolPanels: [
    {
      name: 'ApplicationPanel',
      title: 'Application',
      render: context => {
        if (context.phase === 'onMount') {
          return '<label>Number of agents: <input type="text" placeholder="Enter count" /></label>';
        }
        return null;
      },
    },
  ],
},
```

**Example: Custom Tool Panel: Bespoke Content**

Providing bespoke HTML in Custom Tool Panels (Vanilla)

- Two Custom Tool Panels use `render` only (no `buttons`):
  - **Hello World** — static HTML returned from `render`
  - **Application** — an input rendered on `onMount` using [`CustomRenderContext`](https://www.adaptabletools.com/docs/reference/customrendercontext.md) lifecycle
- The AdapTable Tool Panel opens on load

Demo project (Vanilla); the files without a marker are shown below:

```text
src/
  adaptableOptions.ts
  agGridModules.ts     [template]
  columnDefs.ts        [template]
  gridOptions.ts       [template]
  index.ts             [template]
  onAdaptableReady.ts
  rowData.ts           [template]
  styles.css           [template]
index.html             [template]
package.json           [template]
tsconfig.json          [template]
```

Files marked `[template]` are the same in every demo; see the [demo template](https://www.adaptabletools.com/llms/demo-template.md#vanilla).

**`src/adaptableOptions.ts`**

```ts
import {AdaptableOptions} from '@adaptabletools/adaptable';
import {WebFramework} from './rowData';

export const adaptableOptions: AdaptableOptions<WebFramework> = {
  primaryKey: 'id',
  adaptableId: 'Custom Tool Panel Bespoke Render',
  toolPanelOptions: {
    customToolPanels: [
      {
        name: 'HelloWorldPanel',
        title: 'Hello World',
        render: () => '<p><strong>Hello World</strong> — static HTML in a Custom Tool Panel.</p>',
      },
      {
        name: 'ApplicationPanel',
        title: 'Application',
        render: context => {
          if (context.phase === 'onMount') {
            return '<label>Number of agents: <input type="text" placeholder="Enter count" /></label>';
          }
          return null;
        },
      },
    ],
  },
  initialState: {
    ToolPanel: {
      ToolPanels: [
        {Name: 'HelloWorldPanel', VisibilityMode: 'expanded'},
        {Name: 'ApplicationPanel', VisibilityMode: 'collapsed'},
        {Name: 'Layout', VisibilityMode: 'collapsed'},
      ],
    },
    Theme: {CurrentTheme: 'dark'},
    Layout: {
      CurrentLayout: 'Standard Layout',
      Layouts: [
        {
          Name: 'Standard Layout',
          TableColumns: [
            'name',
            'language',
            'github_stars',
            'license',
            'has_projects',
            'has_pages',
            'created_at',
            'has_wiki',
            'updated_at',
            'pushed_at',
            'github_watchers',
            'week_issue_change',
          ],
          AutoSizeColumns: true,
        },
      ],
    },
  },
};
```

**`src/onAdaptableReady.ts`**

```ts
import {AdaptableReadyInfo} from '@adaptabletools/adaptable';

export const onAdaptableReady = ({adaptableApi}: AdaptableReadyInfo) => {
  adaptableApi.toolPanelApi.openAdapTableToolPanel();
};
```

<!-- /framework -->

<!-- framework: angular -->
### Angular

When Adaptable Buttons are not enough, you can provide bespoke content in a Custom Tool Panel.

This is done using the `frameworkComponent` property in [`CustomToolPanel`](https://www.adaptabletools.com/docs/reference/customtoolpanel.md) — typically `{ type: MyComponent, onSetup: ({ adaptableApi }) => ({ ... }) }`.

See [Building Custom Components](https://www.adaptabletools.com/docs/ui-tutorial-building-custom-components/index.md) for `AngularFrameworkComponent` details

### Providing Bespoke Tool Panel Content

In this example we are providing a SlideToggle button, which is a standard Angular Component.

The implementation that we provide is entirely generic and reusable, as the I/O params are set via the `onSetup()` function in the `frameworkComponent`.

```ts
@Component({
  selector: 'slide-toggle',
  template: `
    <label class="switch">
      <input
        class="switch-input"
        type="checkbox"
        [checked]="active"
        (change)="onToggle()" />
      <span
        class="switch-label"
        [attr.data-on]="onText"
        [attr.data-off]="offText"
        [style.background]="active ? onColor : offColor"></span>
      <span class="switch-handle"></span>
    </label>
  `,
  styles: [
    `
      // [...]
    `,
  ],
})
export class SlideToggleComponent {
  active = false;

  onText = 'ON';
  onColor = 'var(--ab-color-success)';

  offText = 'OFF';
  offColor = 'var(--ab-color-info)';

  constructor(@Inject(ADAPTABLE_API) private adaptableApi: AdaptableApi) {}

  onToggle() {
    this.active = !this.active;
    this.onChange(this.active);
  }

  onChange(toggleValue: boolean) {
    // overwritten in onSetup()
  }
}
```

Register the component on `frameworkComponent` in `toolPanelOptions.customToolPanels`.

Set `name` and `title` as in [Wiring Up Custom Tool Panels](#wiring-up-custom-tool-panels); use `onSetup` to pass props and callbacks.

```ts {3}
const adaptableOptions: AdaptableOptions = {
  toolPanelOptions: {
    customToolPanels: [
      {
        name: 'LayoutToggle',
        title: 'Current layout',
        frameworkComponent: {
          type: SlideToggleComponent,
          onSetup: ({adaptableApi}): Partial<SlideToggleComponent> => {
            return {
              onText: 'Pivot',
              offText: 'Standard',
              onChange: toggleValue => {
                if (toggleValue) {
                  adaptableApi.layoutApi.setLayout('Pivot Cols Layout');
                } else {
                  adaptableApi.layoutApi.setLayout('Standard Layout');
                }
              },
            };
          },
        },
      },
    ],
  },
};
```

**Example: Angular Components: Custom Tool Panels**

Providing Angular Components as Custom Tool Panels

- In this demo we provide 3 Custom Tool Panels:
  - a SlideToggle button switching between standard and pivot layout
  - a CustomQuickSearch toolbar which is disabled when in pivot mode
  - a SlideToggle button enabling/disabling the gradient style for the `GitHub Stars` column
- The `Layout toggle` and `Gradient Style toggle` re-use __the same toggle component__ but with different configurations.

Demo project (Angular); the files without a marker are shown below:

```text
src/
  app/
    adaptableOptions.ts
    agGridModules.ts           [template]
    app.component.ts           [template]
    app.module.ts
    columnDefs.ts              [template]
    gridOptions.ts             [template]
    onAdaptableReady.ts
    quick-search.component.ts
    rowData.ts                 [template]
    slide-toggle.component.ts
    styles.css                 [template]
  index.html                   [template]
  main.ts                      [template]
  polyfills.ts                 [template]
package.json                   [template]
tsconfig.json                  [template]
```

Files marked `[template]` are the same in every demo; see the [demo template](https://www.adaptabletools.com/llms/demo-template.md#angular).

**`src/app/adaptableOptions.ts`**

```ts
import {AdaptableOptions} from '@adaptabletools/adaptable-angular-aggrid';
import {SlideToggleComponent} from './slide-toggle.component';
import {QuickSearchComponent} from './quick-search.component';
import {WebFramework} from './rowData';

export const adaptableOptions: AdaptableOptions<WebFramework> = {
  primaryKey: 'id',
  adaptableId: 'Custom Tool Panel Demo',
  toolPanelOptions: {
    customToolPanels: [
      {
        name: 'LayoutToggle',
        title: 'Current layout',
        frameworkComponent: {
          type: SlideToggleComponent,
          // configure custom content & behaviour
          onSetup: ({adaptableApi}): Partial<SlideToggleComponent> => {
            return {
              onText: 'Pivot',
              offText: 'Standard',
              onChange: toggleValue => {
                if (toggleValue) {
                  adaptableApi.layoutApi.setLayout('Pivot Cols Layout');
                } else {
                  adaptableApi.layoutApi.setLayout('Standard Layout');
                }
              },
            };
          },
        },
      },
      {
        name: 'CustomQuickSearch',
        title: 'Quick Search',
        frameworkComponent: {
          type: QuickSearchComponent,
        },
      },
      {
        name: 'StyledColumnToggle',
        title: 'GitHub Stars Gradient',
        frameworkComponent: {
          type: SlideToggleComponent,
          // configure custom content & behaviour
          onSetup: ({adaptableApi}): Partial<SlideToggleComponent> => {
            return {
              active: true,
              onColor: '#a52a2a',
              offColor: 'var(--ab-color-primary-foreground)',
              onChange: toggleValue => {
                const styledColumn =
                  adaptableApi.styledColumnApi.getStyledColumnForColumnId(
                    'github_stars'
                  );
                if (toggleValue) {
                  adaptableApi.styledColumnApi.unSuspendStyledColumn(
                    styledColumn
                  );
                } else {
                  adaptableApi.styledColumnApi.suspendStyledColumn(
                    styledColumn
                  );
                }
              },
            };
          },
        },
      },
    ],
  },
  initialState: {
    ToolPanel: {
      ToolPanels: [
        {
          Name: 'LayoutToggle',
          VisibilityMode: 'expanded',
        },
        {
          Name: 'CustomQuickSearch',
          VisibilityMode: 'expanded',
        },
        {
          Name: 'StyledColumnToggle',
          VisibilityMode: 'expanded',
        },
        {
          Name: 'Alert',
        },
        {
          Name: 'BulkUpdate',
        },
        {
          Name: 'CellSummary',
        },
        {
          Name: 'Dashboard',
        },
      ],
    },
    Theme: {CurrentTheme: 'dark'},
    Layout: {
      CurrentLayout: 'Standard Layout',
      Layouts: [
        {
          Name: 'Standard Layout',
          TableColumns: [
            'name',
            'language',
            'github_stars',
            'license',
            'created_at',
            'has_wiki',
            'updated_at',
            'pushed_at',
            'github_watchers',
            'description',
            'open_issues_count',
            'closed_issues_count',
            'open_pr_count',
            'closed_pr_count',
            'has_projects',
            'has_pages',
            'week_issue_change',
          ],
          AutoSizeColumns: true,
        },
        {
          Name: 'Pivot Cols Layout',
          PivotColumns: ['license'],
          PivotGroupedColumns: ['language'],
          PivotAggregationColumns: [
            {ColumnId: 'github_watchers', AggFunc: 'count'},
            {ColumnId: 'github_stars', AggFunc: 'sum'},
          ],
        },
      ],
    },
    StyledColumn: {
      StyledColumns: [
        {
          ColumnId: 'github_stars',
          Name: 'github_stars Gradient',
          GradientStyle: {
            RangeValueType: 'Number',
            CellRanges: [{Min: 'Col-Min', Max: 'Col-Max', Color: '#a52a2a'}],
          },
        },
      ],
    },
    QuickSearch: {
      CellMatchStyle: {
        BackColor: '#a1c0d4',
      },
    },
  },
};
```

**`src/app/slide-toggle.component.ts`**

```ts
import {
  ADAPTABLE_API,
  AdaptableApi,
} from '@adaptabletools/adaptable-angular-aggrid';
import {Component, Inject} from '@angular/core';

@Component({
  standalone: false,
  selector: 'slide-toggle',
  template: `
    <label class="switch">
      <input
        class="switch-input"
        type="checkbox"
        [checked]="active"
        (change)="onToggle()" />
      <span
        class="switch-label"
        [attr.data-on]="onText"
        [attr.data-off]="offText"
        [style.background]="active ? onColor : offColor"></span>
      <span class="switch-handle"></span>
    </label>
  `,
  styles: [
    `
      .switch {
        position: relative;
        display: block;
        width: 100px;
        height: 30px;
        padding: 3px;
        margin: 2px;
        background: -webkit-linear-gradient(top, #eeeeee, #ffffff 25px);
        border-radius: 18px;
        box-shadow:
          inset 0 -1px white,
          inset 0 1px 1px rgba(0, 0, 0, 0.05);
        cursor: pointer;
        box-sizing: content-box;
      }
      .switch-input {
        position: absolute;
        top: 0;
        left: 0;
        opacity: 0;
        box-sizing: content-box;
      }
      .switch-input:checked ~ .switch-label {
        box-shadow:
          inset 0 1px 2px rgba(0, 0, 0, 0.15),
          inset 0 0 3px rgba(0, 0, 0, 0.2);
      }
      .switch-input:checked ~ .switch-label:before {
        opacity: 0;
      }
      .switch-input:checked ~ .switch-label:after {
        opacity: 1;
      }
      .switch-input:checked ~ .switch-handle {
        left: 74px;
        box-shadow: -1px 1px 5px rgba(0, 0, 0, 0.2);
      }
      .switch-label {
        position: relative;
        display: block;
        height: inherit;
        background: #eceeef;
        font-size: 10px;
        text-transform: uppercase;
        border-radius: inherit;
        box-shadow:
          inset 0 1px 2px rgba(0, 0, 0, 0.12),
          inset 0 0 2px rgba(0, 0, 0, 0.15);
        box-sizing: content-box;
        transition: All 0.3s ease;
        -webkit-transition: All 0.3s ease;
        -moz-transition: All 0.3s ease;
        -o-transition: All 0.3s ease;
      }
      .switch-label:before {
        position: absolute;
        top: 50%;
        margin-top: -0.5em;
        line-height: 1;
        -webkit-transition: inherit;
        -moz-transition: inherit;
        -o-transition: inherit;
        transition: inherit;
        box-sizing: content-box;
        content: attr(data-off);
        right: 11px;
        color: #ffffff;
        text-shadow: 0 1px rgba(0, 0, 0, 0.2);
      }
      .switch-label:after {
        position: absolute;
        top: 50%;
        margin-top: -0.5em;
        line-height: 1;
        -webkit-transition: inherit;
        -moz-transition: inherit;
        -o-transition: inherit;
        transition: inherit;
        box-sizing: content-box;
        content: attr(data-on);
        left: 11px;
        color: #ffffff;
        text-shadow: 0 1px rgba(0, 0, 0, 0.2);
        opacity: 0;
      }
      .switch-handle {
        position: absolute;
        top: 4px;
        left: 4px;
        width: 28px;
        height: 28px;
        background: -webkit-linear-gradient(top, #ffffff 40%, #f0f0f0);
        border-radius: 100%;
        box-shadow: 1px 1px 5px rgba(0, 0, 0, 0.2);
        transition: All 0.3s ease;
        -webkit-transition: All 0.3s ease;
        -moz-transition: All 0.3s ease;
        -o-transition: All 0.3s ease;
      }
      .switch-handle:before {
        content: '';
        position: absolute;
        top: 50%;
        left: 50%;
        margin: -6px 0 0 -6px;
        width: 12px;
        height: 12px;
        background: -webkit-linear-gradient(top, #eeeeee, #ffffff);
        border-radius: 6px;
        box-shadow: inset 0 1px rgba(0, 0, 0, 0.02);
      }
    `,
  ],
})
export class SlideToggleComponent {
  active = false;

  onText = 'ON';
  onColor = 'var(--ab-color-success)';

  offText = 'OFF';
  offColor = 'var(--ab-color-info)';

  constructor(@Inject(ADAPTABLE_API) private adaptableApi: AdaptableApi) {}

  onToggle() {
    this.active = !this.active;
    this.onChange(this.active);
  }

  onChange(toggleValue: boolean) {
    // overwritten in configuration
  }
}
```

**`src/app/quick-search.component.ts`**

```ts
import {
  ADAPTABLE_API,
  AdaptableApi,
} from '@adaptabletools/adaptable-angular-aggrid';
import {Component, Inject} from '@angular/core';

@Component({
  standalone: false,
  selector: 'quick-search',
  template: `
    <div class="quickSearchComponent">
      <input
        type="text"
        class="ab-Input ab-Input--type-text"
        [disabled]="isDisabled"
        (input)="onSearchChange($event)" />
      <button
        type="button"
        class="ab-SimpleButton ab-SimpleButton--font-weight=normal ab-SimpleButton--variant-raised"
        [class.ab-SimpleButton--tone-info]="!isDisabled"
        [disabled]="isDisabled"
        (click)="resetQuickSearch()">
        Clear
      </button>
    </div>
  `,
  styles: [
    `
      .ab-Input.ab-Input--type-text {
        border: var(--ab-cmp-input__border);
      }
      .quickSearchComponent {
        display: flex;
        align-items: center;
        gap: calc(var(--ab-base-space) * 2);
      }
    `,
  ],
})
export class QuickSearchComponent {
  isDisabled = false;

  constructor(@Inject(ADAPTABLE_API) private adaptableApi: AdaptableApi) {
    // disable Quick Search when in Pivot mode
    const isCurrentLayoutInPivotMode = () =>
      this.adaptableApi.layoutApi.isCurrentLayoutPivot();
    this.isDisabled = isCurrentLayoutInPivotMode();

    this.adaptableApi.eventApi.on('LayoutChanged', () => {
      this.isDisabled = isCurrentLayoutInPivotMode();
      if (this.isDisabled) {
        // just to avoid yet another dependency on @angular/forms
        (document.querySelector('input.ab-Input') as HTMLInputElement).value =
          '';
      }
    });
  }

  onSearchChange(event: any) {
    const searchTerm = event.target?.value || '';
    this.adaptableApi.quickSearchApi.runQuickSearch(searchTerm);
  }

  resetQuickSearch() {
    this.adaptableApi.quickSearchApi.clearQuickSearch();
  }
}
```

**`src/app/onAdaptableReady.ts`**

```ts
import {AdaptableReadyInfo} from '@adaptabletools/adaptable-angular-aggrid';

export const onAdaptableReady = ({adaptableApi}: AdaptableReadyInfo) => {
  adaptableApi.toolPanelApi.openAdapTableToolPanel();
};
```

**`src/app/app.module.ts`**

```ts
import {BrowserModule} from '@angular/platform-browser';
import {NgModule} from '@angular/core';

import {AgGridModule} from 'ag-grid-angular';
import {AdaptableAngularAgGridModule} from '@adaptabletools/adaptable-angular-aggrid';
import {AppComponent} from './app.component';
import {SlideToggleComponent} from './slide-toggle.component';
import {QuickSearchComponent} from './quick-search.component';

@NgModule({
  declarations: [AppComponent, SlideToggleComponent, QuickSearchComponent],
  imports: [BrowserModule, AgGridModule, AdaptableAngularAgGridModule],
  providers: [],
  bootstrap: [AppComponent],
  // @ts-ignore FIXME #AFL required only for Codesandbox (which uses an old rendering engine), since Ivy (Angular >9) 'entryComponents' is no longer required in standalone apps
  entryComponents: [SlideToggleComponent, QuickSearchComponent],
})
export class AppModule {}
```

<!-- /framework -->

<!-- framework: react -->
### React

When Adaptable Buttons are not enough, you can provide bespoke content in a Custom Tool Panel.

This is done using the `frameworkComponent` property in [`CustomToolPanel`](https://www.adaptabletools.com/docs/reference/customtoolpanel.md) — a function that receives `{ adaptableApi }` and returns JSX.

See [Building Custom Components](https://www.adaptabletools.com/docs/ui-tutorial-building-custom-components/index.md) for `ReactFrameworkComponent` details

### Providing Bespoke Tool Panel Content

This is a standard React Component of type `ReactFrameworkComponent`.

It can be as complicated and configurable as required.

Developers will typically provide a reference to the [Adaptable API](https://www.adaptabletools.com/docs/technical-reference-adaptable-api/index.md) for use when controls in the Panel are accessed.

```tsx
export const SlideToggle = (props: SlideToggleProps) => {
  const {
    defaultValue = false,
    onText = 'ON',
    onColor = 'var(--ab-color-success)',
    offText = 'OFF',
    offColor = 'var(--ab-color-info)',
    onToggleChange,
  } = props;

  const [toggleValue, setToggleValue] = useState(defaultValue);

  return (
    <>
      <label className="switch">
        <input
          className="switch-input"
          type="checkbox"
          checked={toggleValue}
          onChange={() => {
            const newValue = !toggleValue;
            setToggleValue(newValue);
            onToggleChange(newValue);
          }}
        />
        <span
          className="switch-label"
          data-on={onText}
          data-off={offText}
          style={{background: toggleValue ? onColor : offColor}}></span>
        <span className="switch-handle"></span>
      </label>
    </>
  );
};
```

Register JSX on `frameworkComponent` in `toolPanelOptions.customToolPanels`.

Set `name` and `title` as in [Wiring Up Custom Tool Panels](#wiring-up-custom-tool-panels).

```tsx {3}
const adaptableOptions: AdaptableOptions = {
  toolPanelOptions: {
    customToolPanels: [
      {
        name: 'LayoutToggle',
        title: 'Current layout',
        frameworkComponent: ({adaptableApi}) => {
          return (
            <SlideToggle
              onText={'Pivot'}
              offText={'Standard'}
              onToggleChange={(toggleValue: boolean) => {
                if (toggleValue) {
                  adaptableApi.layoutApi.setLayout('Pivot Cols Layout');
                } else {
                  adaptableApi.layoutApi.setLayout('Standard Layout');
                }
              }}
            />
          );
        },
      },
    ],
  },
};
```

**Example: React Components as Custom Tool Panels**

Providing React Components as Custom Tool Panels

- Three Custom Tool Panels: layout toggle, custom quick search, and GitHub Stars gradient toggle

Demo project (React); the files without a marker are shown below:

```text
src/
  agGridModules.ts       [template]
  App.tsx
  columnDefs.ts          [template]
  CustomQuickSearch.tsx
  gridOptions.ts         [template]
  index.tsx              [template]
  onAdaptableReady.ts
  rowData.ts             [template]
  SlideToggle.tsx
  styles.css             [template + shown below]
package.json             [template]
tsconfig.json            [template]
```

Files marked `[template]` are the same in every demo; see the [demo template](https://www.adaptabletools.com/llms/demo-template.md#react).

**`src/App.tsx`**

```ts
import * as React from 'react';
import {useState} from 'react';
import {
  Adaptable,
  AdaptableApi,
  AdaptableOptions,
  AdaptableReadyInfo,
} from '@adaptabletools/adaptable-react-aggrid';

import {GridOptions} from 'ag-grid-enterprise';

// import adaptable css
import '@adaptabletools/adaptable-react-aggrid/index.css';
// import aggrid themes (using Balham theme)

import './styles.css';

import {onAdaptableReady} from './onAdaptableReady';
import {gridOptions} from './gridOptions';
import {agGridModules} from './agGridModules';
import {SlideToggle} from './SlideToggle';
import {CustomQuickSearch} from './CustomQuickSearch';
import {WebFramework} from './rowData';

const App: React.FunctionComponent = () => {
  const adaptableApiRef = React.useRef<AdaptableApi>(null);

  const [adaptOptions, setAdaptOptions] = useState<
    AdaptableOptions<WebFramework>
  >({
    primaryKey: 'id',
    adaptableId: 'Custom Tool Panel Demo',
    stateOptions: {loadState: () => Promise.resolve({})},
    toolPanelOptions: {
      customToolPanels: [
        {
          name: 'LayoutToggle',
          title: 'Current layout',
          frameworkComponent: ({adaptableApi}) => {
            return (
              <SlideToggle
                onText={'Pivot'}
                offText={'Standard'}
                onToggleChange={(toggleValue: boolean) => {
                  if (toggleValue) {
                    adaptableApi.layoutApi.setLayout('Pivot Cols Layout');
                  } else {
                    adaptableApi.layoutApi.setLayout('Standard Layout');
                  }
                }}
              />
            );
          },
        },
        {
          name: 'StyledColumnToggle',
          title: 'GitHub Stars Gradient',
          frameworkComponent: ({adaptableApi}) => {
            return (
              <SlideToggle
                defaultValue={true}
                onColor={'#a52a2a'}
                offColor={'var(--ab-color-primary-foreground)'}
                onToggleChange={(toggleValue: boolean) => {
                  const styledColumn =
                    adaptableApi.styledColumnApi.getStyledColumnForColumnId(
                      'github_stars'
                    );
                  if (toggleValue) {
                    adaptableApi.styledColumnApi.unSuspendStyledColumn(
                      styledColumn
                    );
                  } else {
                    adaptableApi.styledColumnApi.suspendStyledColumn(
                      styledColumn
                    );
                  }
                }}
              />
            );
          },
        },
        {
          name: 'CustomQuickSearch',
          title: 'Quick Search',
          frameworkComponent: ({adaptableApi}) => {
            return <CustomQuickSearch adaptableApi={adaptableApi} />;
          },
        },
      ],
    },
    initialState: {
      ToolPanel: {
        ToolPanels: [
          {
            Name: 'LayoutToggle',
            VisibilityMode: 'expanded',
          },
          {
            Name: 'CustomQuickSearch',
            VisibilityMode: 'expanded',
          },
          {
            Name: 'StyledColumnToggle',
            VisibilityMode: 'expanded',
          },
          {
            Name: 'Alert',
          },
          {
            Name: 'BulkUpdate',
          },
          {
            Name: 'CellSummary',
          },
          {
            Name: 'Dashboard',
          },
        ],
      },
      Theme: {CurrentTheme: 'dark'},
      Layout: {
        CurrentLayout: 'Standard Layout',
        Layouts: [
          {
            Name: 'Standard Layout',
            TableColumns: [
              'name',
              'language',
              'github_stars',
              'topics',
              'license',
              'created_at',
              'has_wiki',
              'updated_at',
              'pushed_at',
              'github_watchers',
              'description',
              'open_issues_count',
              'closed_issues_count',
              'open_pr_count',
              'closed_pr_count',
              'has_projects',
              'has_pages',
              'week_issue_change',
            ],
            AutoSizeColumns: true,
          },
          {
            Name: 'Pivot Cols Layout',
            PivotColumns: ['license'],
            PivotGroupedColumns: ['language'],
            PivotAggregationColumns: [
              {
                ColumnId: 'github_watchers',
                AggFunc: 'sum',
              },
              {
                ColumnId: 'github_stars',
                AggFunc: 'sum',
              },
            ],
          },
        ],
      },
      StyledColumn: {
        StyledColumns: [
          {
            ColumnId: 'github_stars',
            Name: 'github_stars Gradient',
            GradientStyle: {
              RangeValueType: 'Number',
              CellRanges: [{Min: 'Col-Min', Max: 'Col-Max', Color: '#a52a2a'}],
            },
          },
        ],
      },
      QuickSearch: {
        CellMatchStyle: {
          BackColor: '#a1c0d4',
        },
      },
    },
  });
  const [agGridOptions, setAgGridOptions] = useState<GridOptions>(gridOptions);

  return (
    <div style={{display: 'flex', flexFlow: 'column', height: '100vh'}}>
      <div id="demoOutputAbove"></div>
      <Adaptable.Provider
        gridOptions={agGridOptions}
        adaptableOptions={adaptOptions}
        modules={[...agGridModules]}
        onAdaptableReady={(adaptableReadyInfo: AdaptableReadyInfo) => {
          // save a reference to adaptable api
          adaptableApiRef.current = adaptableReadyInfo.adaptableApi;
          onAdaptableReady(adaptableReadyInfo);
        }}>
        <Adaptable.UI style={{flex: 'none'}} />
        <Adaptable.AgGridReact />
      </Adaptable.Provider>
      <div id="demoOutputBelow"></div>
    </div>
  );
};
export default App;
```

**`src/SlideToggle.tsx`**

```ts
import * as React from 'react';
import {useState} from 'react';

export interface SlideToggleProps {
  defaultValue?: boolean;
  onText?: string;
  onColor?: string;
  offText?: string;
  offColor?: string;
  onToggleChange(toggleValue: boolean): void;
}
export const SlideToggle = (props: SlideToggleProps) => {
  const {
    defaultValue = false,
    onText = 'ON',
    onColor = 'var(--ab-color-success)',
    offText = 'OFF',
    offColor = 'var(--ab-color-info)',
    onToggleChange,
  } = props;

  const [toggleValue, setToggleValue] = useState(defaultValue);

  return (
    <>
      <label className="switch">
        <input
          className="switch-input"
          type="checkbox"
          checked={toggleValue}
          onChange={() => {
            const newValue = !toggleValue;
            setToggleValue(newValue);
            onToggleChange(newValue);
          }}
        />
        <span
          className="switch-label"
          data-on={onText}
          data-off={offText}
          style={{background: toggleValue ? onColor : offColor}}></span>
        <span className="switch-handle"></span>
      </label>
    </>
  );
};
```

**`src/CustomQuickSearch.tsx`**

```ts
import * as React from 'react';
import {useEffect, useState} from 'react';
import {AdaptableApi} from '@adaptabletools/adaptable-react-aggrid';

export const CustomQuickSearch = ({
  adaptableApi,
}: {
  adaptableApi: AdaptableApi;
}) => {
  const [searchTerm, setSearchTerm] = useState('');

  const isCurrentLayoutInPivotMode = () =>
    adaptableApi.layoutApi.isCurrentLayoutPivot();
  const [isDisabled, setIsDisabled] = useState(isCurrentLayoutInPivotMode());
  useEffect(() => {
    const unsubscribeListener = adaptableApi.eventApi.on(
      'LayoutChanged',
      () => {
        const isPivotLayout = isCurrentLayoutInPivotMode();
        setIsDisabled(isPivotLayout);
        if (isPivotLayout) {
          setSearchTerm('');
        }
      }
    );
    return () => {
      unsubscribeListener?.();
    };
  }, []);

  useEffect(() => {
    adaptableApi.quickSearchApi.runQuickSearch(searchTerm);
  }, [searchTerm]);

  const onSearchChange = (event: any) => {
    const searchText = event.target?.value || '';
    setSearchTerm(searchText);
  };

  return (
    <div className="customQuickSearch">
      <input
        type="text"
        className="ab-Input ab-Input--type-text"
        value={searchTerm}
        disabled={isDisabled}
        onChange={onSearchChange}
      />
      <button
        type="button"
        className={`ab-SimpleButton ab-SimpleButton--font-weight=normal ab-SimpleButton--variant-raised ${
          !isDisabled ? 'ab-SimpleButton--tone-info' : ''
        }`}
        disabled={isDisabled}
        onClick={() => setSearchTerm('')}>
        Clear
      </button>
    </div>
  );
};
```

**`src/onAdaptableReady.ts`**

```ts
import {AdaptableReadyInfo} from '@adaptabletools/adaptable-react-aggrid';

export const onAdaptableReady = ({adaptableApi}: AdaptableReadyInfo) => {
  adaptableApi.toolPanelApi.openAdapTableToolPanel();
};
```

**`src/styles.css`**

```css
/*
  toggle-switch
*/
.switch {
  position: relative;
  display: block;
  width: 100px;
  height: 30px;
  padding: 3px;
  margin: 2px;
  background: -webkit-linear-gradient(top, #eeeeee, #ffffff 25px);
  border-radius: 18px;
  box-shadow: inset 0 -1px white, inset 0 1px 1px rgba(0, 0, 0, 0.05);
  cursor: pointer;
  box-sizing: content-box;
}
.switch-input {
  position: absolute;
  top: 0;
  left: 0;
  opacity: 0;
  box-sizing: content-box;
}
.switch-input:checked ~ .switch-label {
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.15),
    inset 0 0 3px rgba(0, 0, 0, 0.2);
}
.switch-input:checked ~ .switch-label:before {
  opacity: 0;
}
.switch-input:checked ~ .switch-label:after {
  opacity: 1;
}
.switch-input:checked ~ .switch-handle {
  left: 74px;
  box-shadow: -1px 1px 5px rgba(0, 0, 0, 0.2);
}
.switch-label {
  position: relative;
  display: block;
  height: inherit;
  background: #eceeef;
  font-size: 10px;
  text-transform: uppercase;
  border-radius: inherit;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.12),
    inset 0 0 2px rgba(0, 0, 0, 0.15);
  box-sizing: content-box;
  transition: All 0.3s ease;
  -webkit-transition: All 0.3s ease;
  -moz-transition: All 0.3s ease;
  -o-transition: All 0.3s ease;
}
.switch-label:before {
  position: absolute;
  top: 50%;
  margin-top: -0.5em;
  line-height: 1;
  -webkit-transition: inherit;
  -moz-transition: inherit;
  -o-transition: inherit;
  transition: inherit;
  box-sizing: content-box;
  content: attr(data-off);
  right: 11px;
  color: #ffffff;
  text-shadow: 0 1px rgba(0, 0, 0, 0.2);
}
.switch-label:after {
  position: absolute;
  top: 50%;
  margin-top: -0.5em;
  line-height: 1;
  -webkit-transition: inherit;
  -moz-transition: inherit;
  -o-transition: inherit;
  transition: inherit;
  box-sizing: content-box;
  content: attr(data-on);
  left: 11px;
  color: #ffffff;
  text-shadow: 0 1px rgba(0, 0, 0, 0.2);
  opacity: 0;
}
.switch-handle {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 28px;
  height: 28px;
  background: -webkit-linear-gradient(top, #ffffff 40%, #f0f0f0);
  border-radius: 100%;
  box-shadow: 1px 1px 5px rgba(0, 0, 0, 0.2);
  transition: All 0.3s ease;
  -webkit-transition: All 0.3s ease;
  -moz-transition: All 0.3s ease;
  -o-transition: All 0.3s ease;
}
.switch-handle:before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  margin: -6px 0 0 -6px;
  width: 12px;
  height: 12px;
  background: -webkit-linear-gradient(top, #eeeeee, #ffffff);
  border-radius: 6px;
  box-shadow: inset 0 1px rgba(0, 0, 0, 0.02);
}

/*
 Custom quick search
*/
.customQuickSearch {
  display: flex;
  align-items: center;
  gap: calc(var(--ab-base-space) * 2);
}
.customQuickSearch .ab-Input.ab-Input--type-text {
  border: var(--ab-cmp-input__border);
}
```



<!-- /framework -->

<!-- framework: vue -->
### Vue

When Adaptable Buttons are not enough, you can provide bespoke content in a Custom Tool Panel.

This is done using the `frameworkComponent` property in [`CustomToolPanel`](https://www.adaptabletools.com/docs/reference/customtoolpanel.md) — typically a factory that returns `h(YourComponent, { ... })`.

See [Building Custom Components](https://www.adaptabletools.com/docs/ui-tutorial-building-custom-components/index.md) for `VueFrameworkComponent` details

### Providing Bespoke Tool Panel Content

This is a standard Vue Component of type `VueFrameworkComponent`.

Developers will typically provide a reference to the [Adaptable API](https://www.adaptabletools.com/docs/technical-reference-adaptable-api/index.md) for use when controls in the Panel are accessed.

```js
const props = defineProps({
  adaptableApi: {
    type: Object,
    required: true,
  },
});

<template>
  <label class="switch">
    <input
      class="switch-input"
      type="checkbox"
      :checked="toggleValue"
      @change="handleChange" />
    <span
      class="switch-label"
      :data-on="props.onText"
      :data-off="props.offText"
      :style="{
        background: toggleValue ? props.onColor : props.offColor,
      }"></span>
    <span class="switch-handle"></span>
  </label>
</template>
```

Register the component with `frameworkComponent` and Vue's `h()` in `toolPanelOptions.customToolPanels`.

Set `name` and `title` as in [Wiring Up Custom Tool Panels](#wiring-up-custom-tool-panels).

```tsx {3}
const adaptableOptions: AdaptableOptions = {
  toolPanelOptions: {
    customToolPanels: [
      {
        name: 'LayoutToggle',
        title: 'Current layout',
        frameworkComponent: ({adaptableApi}) => {
          return h(SlideToggle, {
            offText: 'Standard',
            offColor: 'var(--ab-color-primary-foreground)',
            onToggleChange: (toggleValue: boolean) => {
              if (toggleValue) {
                adaptableApi.layoutApi.setLayout('Pivot Cols Layout');
              } else {
                adaptableApi.layoutApi.setLayout('Standard Layout');
              }
            },
          });
        },
      },
    ],
  },
};
```

**Example: Vue Components as Custom Tool Panels**

Providing Vue Components as Custom Tool Panels

- Three Custom Tool Panels: layout toggle, custom quick search, and GitHub Stars gradient toggle

Demo project (Vue); the files without a marker are shown below:

```text
public/
  index.html             [template]
src/
  agGridModules.ts       [template]
  App.vue
  columnDefs.ts          [template]
  CustomQuickSearch.vue
  gridOptions.ts         [template]
  main.ts                [template]
  onAdaptableReady.ts    [template]
  rowData.ts             [template]
  shims-vue.d.ts         [template]
  SlideToggle.vue
  styles.css             [template]
.babelrc                 [template]
package.json             [template]
tsconfig.json            [template]
```

Files marked `[template]` are the same in every demo; see the [demo template](https://www.adaptabletools.com/llms/demo-template.md#vue).

**`src/App.vue`**

```ts
<script setup lang="ts">
import {h} from 'vue';
import {
  AdaptableProvider,
  AdaptableAgGridVue,
  AdaptableUI,
  AdaptableOptions,
} from '@adaptabletools/adaptable-vue3-aggrid';

import {onAdaptableReady} from './onAdaptableReady';
import {gridOptions} from './gridOptions';
import {agGridModules} from './agGridModules';
import {WebFramework} from './rowData';
import CustomQuickSearch from './CustomQuickSearch.vue';
import SlideToggle from './SlideToggle.vue';

const adaptableOpts: AdaptableOptions<WebFramework> = {
  primaryKey: 'id',
  adaptableId: 'Custom Tool Panel Demo',
  stateOptions: {loadState: () => Promise.resolve({})},
  toolPanelOptions: {
    customToolPanels: [
      {
        name: 'LayoutToggle',
        title: 'Current layout',
        frameworkComponent: ({adaptableApi}) => {
          return h(SlideToggle, {
            offText: 'Standard',
            offColor: 'var(--ab-color-primary-foreground)',
            onToggleChange: (toggleValue: boolean) => {
              if (toggleValue) {
                adaptableApi.layoutApi.setLayout('Pivot Cols Layout');
              } else {
                adaptableApi.layoutApi.setLayout('Standard Layout');
              }
            },
          });
        },
      },
      {
        name: 'StyledColumnToggle',
        title: 'GitHub Stars Gradient',
        frameworkComponent: ({adaptableApi}) => {
          return h(SlideToggle, {
            defaultValue: true,
            onColor: '#a52a2a',
            offColor: 'var(--ab-color-primary-foreground)',
            onToggleChange: toggleValue => {
              const styledColumn =
                adaptableApi.styledColumnApi.getStyledColumnForColumnId(
                  'github_stars'
                );
              if (toggleValue) {
                adaptableApi.styledColumnApi.unSuspendStyledColumn(
                  styledColumn
                );
              } else {
                adaptableApi.styledColumnApi.suspendStyledColumn(styledColumn);
              }
            },
          });
        },
      },
      {
        name: 'CustomQuickSearch',
        title: 'Quick Search',
        frameworkComponent: ({adaptableApi}) =>
          h(CustomQuickSearch, {adaptableApi}),
      },
    ],
  },
  initialState: {
    ToolPanel: {
      ToolPanels: [
        {
          Name: 'LayoutToggle',
          VisibilityMode: 'expanded',
        },
        {
          Name: 'CustomQuickSearch',
          VisibilityMode: 'expanded',
        },
        {
          Name: 'StyledColumnToggle',
          VisibilityMode: 'expanded',
        },
        {
          Name: 'Alert',
        },
        {
          Name: 'BulkUpdate',
        },
        {
          Name: 'CellSummary',
        },
        {
          Name: 'Dashboard',
        },
      ],
    },
    Theme: {CurrentTheme: 'dark'},
    Layout: {
      CurrentLayout: 'Standard Layout',
      Layouts: [
        {
          Name: 'Standard Layout',
          TableColumns: [
            'name',
            'language',
            'github_stars',
            'license',
            'created_at',
            'has_wiki',
            'updated_at',
            'pushed_at',
            'github_watchers',
            'description',
            'open_issues_count',
            'closed_issues_count',
            'open_pr_count',
            'closed_pr_count',
            'has_projects',
            'has_pages',
            'week_issue_change',
          ],
          AutoSizeColumns: true,
        },
        {
          Name: 'Pivot Cols Layout',
          PivotColumns: ['license'],
          PivotGroupedColumns: ['language'],
          PivotAggregationColumns: [
            {
              ColumnId: 'github_watchers',
              AggFunc: 'sum',
            },
            {
              ColumnId: 'github_stars',
              AggFunc: 'sum',
            },
          ],
        },
      ],
    },
    StyledColumn: {
      StyledColumns: [
        {
          ColumnId: 'github_stars',
          Name: 'github_stars Gradient',  
          GradientStyle: {
            RangeValueType: 'Number',
            CellRanges: [{Min: 'Col-Min', Max: 'Col-Max', Color: '#a52a2a'}],
          },
        },
      ],
    },
    QuickSearch: {
      Style: {
        BackColor: '#a1c0d4',
      },
    },
  },
};
</script>

<template>
  <AdaptableProvider
    :gridOptions="gridOptions"
    :adaptableOptions="adaptableOpts"
    :modules="agGridModules"
    @onAdaptableReady="onAdaptableReady">
    <div style="display: flex; flex-direction: column; height: 100vh">
      <AdaptableUI />
      <AdaptableAgGridVue style="flex: 1" />
    </div>
  </AdaptableProvider>
</template>
```

**`src/SlideToggle.vue`**

```ts
<script setup lang="ts">
import {ref} from 'vue';

const props = defineProps({
  defaultValue: {
    type: Boolean,
    default: false,
  },
  onText: {
    type: String,
    default: 'ON',
  },
  onColor: {
    type: String,
    default: 'var(--ab-color-success)',
  },
  offText: {
    type: String,
    default: 'OFF',
  },
  offColor: {
    type: String,
    default: 'var(--ab-color-info)',
  },
});

const emit = defineEmits<{
  (e: 'toggleChange', value: boolean): boolean;
}>();

const toggleValue = ref(props.defaultValue);

function handleChange() {
  toggleValue.value = !toggleValue.value;
  emit('toggleChange', toggleValue.value);
}
</script>

<template>
  <label class="switch">
    <input
      class="switch-input"
      type="checkbox"
      :checked="toggleValue"
      @change="handleChange" />
    <span
      class="switch-label"
      :data-on="props.onText"
      :data-off="props.offText"
      :style="{
        background: toggleValue ? props.onColor : props.offColor,
      }"></span>
    <span class="switch-handle"></span>
  </label>
</template>

<style scoped>
.switch {
  position: relative;
  display: block;
  width: 100px;
  height: 30px;
  padding: 3px;
  margin: 2px;
  background: linear-gradient(to bottom, #eeeeee, #ffffff 25px);
  border-radius: 18px;
  box-shadow:
    inset 0 -1px white,
    inset 0 1px 1px rgba(0, 0, 0, 0.05);
  cursor: pointer;
  box-sizing: content-box;
}
.switch-input {
  position: absolute;
  top: 0;
  left: 0;
  opacity: 0;
  box-sizing: content-box;
}
.switch-input:checked ~ .switch-label {
  box-shadow:
    inset 0 1px 2px rgba(0, 0, 0, 0.15),
    inset 0 0 3px rgba(0, 0, 0, 0.2);
}
.switch-input:checked ~ .switch-label:before {
  opacity: 0;
}
.switch-input:checked ~ .switch-label:after {
  opacity: 1;
}
.switch-input:checked ~ .switch-handle {
  left: 74px;
  box-shadow: -1px 1px 5px rgba(0, 0, 0, 0.2);
}
.switch-label {
  position: relative;
  display: block;
  height: inherit;
  background: #eceeef;
  font-size: 10px;
  text-transform: uppercase;
  border-radius: inherit;
  box-shadow:
    inset 0 1px 2px rgba(0, 0, 0, 0.12),
    inset 0 0 2px rgba(0, 0, 0, 0.15);
  box-sizing: content-box;
  transition: All 0.3s ease;
  -webkit-transition: All 0.3s ease;
  -moz-transition: All 0.3s ease;
  -o-transition: All 0.3s ease;
}
.switch-label:before {
  position: absolute;
  top: 50%;
  margin-top: -0.5em;
  line-height: 1;
  -webkit-transition: inherit;
  -moz-transition: inherit;
  -o-transition: inherit;
  transition: inherit;
  box-sizing: content-box;
  content: attr(data-off);
  right: 11px;
  color: #ffffff;
  text-shadow: 0 1px rgba(0, 0, 0, 0.2);
}
.switch-label:after {
  position: absolute;
  top: 50%;
  margin-top: -0.5em;
  line-height: 1;
  -webkit-transition: inherit;
  -moz-transition: inherit;
  -o-transition: inherit;
  transition: inherit;
  box-sizing: content-box;
  content: attr(data-on);
  left: 11px;
  color: #ffffff;
  text-shadow: 0 1px rgba(0, 0, 0, 0.2);
  opacity: 0;
}
.switch-handle {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 28px;
  height: 28px;
  background: linear-gradient(to bottom, #ffffff 40%, #f0f0f0);
  border-radius: 100%;
  box-shadow: 1px 1px 5px rgba(0, 0, 0, 0.2);
  transition: All 0.3s ease;
  -webkit-transition: All 0.3s ease;
  -moz-transition: All 0.3s ease;
  -o-transition: All 0.3s ease;
}
.switch-handle:before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  margin: -6px 0 0 -6px;
  width: 12px;
  height: 12px;
  background: linear-gradient(to bottom, #eeeeee, #ffffff);
  border-radius: 6px;
  box-shadow: inset 0 1px rgba(0, 0, 0, 0.02);
}
</style>
```

**`src/CustomQuickSearch.vue`**

```ts
<script setup lang="ts">
import {ref, onMounted, onUnmounted, watch, PropType} from 'vue';

const props = defineProps({
  adaptableApi: {
    type: Object,
    required: true,
  },
});

const searchTerm = ref('');
const isDisabled = ref(isCurrentLayoutInPivotMode());

function isCurrentLayoutInPivotMode() {
  return !!props.adaptableApi.layoutApi.isCurrentLayoutPivot();
}

function onSearchChange(event) {
  searchTerm.value = event.target.value || '';
}

function clearSearch() {
  searchTerm.value = '';
}

onMounted(() => {
  const unsubscribeListener = props.adaptableApi.eventApi.on(
    'LayoutChanged',
    () => {
      const isPivotLayout = isCurrentLayoutInPivotMode();
      isDisabled.value = isPivotLayout;
      if (isPivotLayout) {
        searchTerm.value = '';
      }
    }
  );

  onUnmounted(() => {
    unsubscribeListener?.();
  });
});

watch(searchTerm, newSearchTerm => {
  props.adaptableApi.quickSearchApi.runQuickSearch(newSearchTerm);
});
</script>

<template>
  <div class="customQuickSearch">
    <input
      type="text"
      class="ab-Input ab-Input--type-text"
      v-model="searchTerm"
      :disabled="isDisabled"
      @input="onSearchChange" />
    <button
      type="button"
      :class="[
        'ab-SimpleButton ab-SimpleButton--font-weight=normal ab-SimpleButton--variant-raised',
        !isDisabled ? 'ab-SimpleButton--tone-info' : '',
      ]"
      :disabled="isDisabled"
      @click="clearSearch">
      Clear
    </button>
  </div>
</template>

<style scoped>
.customQuickSearch {
  display: flex;
  align-items: center;
  gap: calc(var(--ab-base-space) * 2);
}
.customQuickSearch .ab-Input.ab-Input--type-text {
  border: var(--ab-cmp-input__border);
}
</style>
```



<!-- /framework -->

- Unlike Dashboard Toolbars, the close button on a Tool Panel is always visible (and not configurable)
- Module Tool Panels always display the Configure button; Custom Tool Panels do not
