---
title: "Side Bar"
enterprise: true
framework: javascript
version: "36.1.0"
---

# Side Bar

This section covers how to configure the Side Bar which contains Tool Panels.

![Side Bar](https://www.ag-grid.com/_astro/sidebar.DcTWoYK1.webp)

## Configuring the Side Bar

The Side Bar is configured using the grid property `sideBar`. The property takes multiple forms to allow easy configuration or more advanced configuration. The different forms for the `sideBar` property are as follows:

| Type | Description |
| --- | --- |
| `undefined` / `null` | No Side Bar provided. |
| `boolean` | Set to `true` to display the Side Bar with default configuration. |
| `string` / `string[]` | Set to `'columns'`, `'filters'` or `'filters-new'` to display the Side Bar with just one of [Columns](https://www.ag-grid.com/javascript-data-grid/tool-panel-columns/), [Filters](https://www.ag-grid.com/javascript-data-grid/tool-panel-filters/) or [New Filters](https://www.ag-grid.com/javascript-data-grid/tool-panel-filters-new/) Tool Panels or an array of some or all of these values. |
| `SideBarDef` (long form) | An object of type `SideBarDef` (explained below) to allow detailed configuration of the Side Bar. Use this to configure the provided Tool Panels (e.g. pass parameters to the columns or filters panel) or to include custom Tool Panels. |

### Boolean Configuration

The default Side Bar contains the Columns and Filters Tool Panels. To use the default Side Bar, set the grid property `sideBar=true`. The Columns panel will be open by default.

The default configuration doesn't allow customisation of the Tool Panels.

#### Boolean Configuration

```ts
import {
  ClientSideRowModelModule,
  GridApi,
  GridOptions,
  ModuleRegistry,
  NumberFilterModule,
  TextFilterModule,
  createGrid,
  enableDevValidations,
} from "ag-grid-community";
import {
  ColumnsToolPanelModule,
  FiltersToolPanelModule,
  PivotModule,
  SetFilterModule,
} from "ag-grid-enterprise";
import { IOlympicData } from "./interfaces";

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

ModuleRegistry.registerModules([
  NumberFilterModule,
  ClientSideRowModelModule,
  ColumnsToolPanelModule,
  FiltersToolPanelModule,
  SetFilterModule,
  PivotModule,
  TextFilterModule,
]);

let gridApi: GridApi<IOlympicData>;

const gridOptions: GridOptions<IOlympicData> = {
  columnDefs: [
    { field: "athlete", filter: "agTextColumnFilter", minWidth: 200 },
    { field: "age" },
    { field: "country", minWidth: 180 },
    { field: "year" },
    { field: "date", minWidth: 150 },
    { field: "gold" },
    { field: "silver" },
    { field: "bronze" },
    { field: "total" },
  ],
  defaultColDef: {
    flex: 1,
    minWidth: 100,
    // allow every column to be aggregated
    enableValue: true,
    // allow every column to be grouped
    enableRowGroup: true,
    // allow every column to be pivoted
    enablePivot: true,
    filter: true,
  },
  autoGroupColumnDef: {
    minWidth: 200,
  },
  sideBar: true,
};

const gridDiv = document.querySelector<HTMLElement>("#myGrid")!;
gridApi = createGrid(gridDiv, gridOptions);

fetch("https://www.ag-grid.com/example-assets/olympic-winners.json")
  .then((response) => response.json())
  .then((data: IOlympicData[]) => gridApi!.setGridOption("rowData", data));
```

[Live example: Boolean Configuration](https://www.ag-grid.com/examples/side-bar/boolean-configuration/typescript)

### String Configuration

To display just one of the provided Tool Panels, set either `sideBar='columns'`, `sideBar='filters'` or `sideBar='filters-new'`. This will display the desired item with default configuration. Alternatively pass some or all of these values as a `string[]`, i.e `sideBar=['columns','filters', 'filters-new']`.

The example below demonstrates using the string configuration. Note the following:

- The grid property `sideBar` is set to `'filters'`.
- The Side Bar is displayed showing only the Filters panel.

#### Side Bar - Only Filters

```ts
import {
  ClientSideRowModelModule,
  GridApi,
  GridOptions,
  ModuleRegistry,
  NumberFilterModule,
  TextFilterModule,
  createGrid,
  enableDevValidations,
} from "ag-grid-community";
import {
  ColumnsToolPanelModule,
  FiltersToolPanelModule,
  PivotModule,
  SetFilterModule,
} from "ag-grid-enterprise";
import { IOlympicData } from "./interfaces";

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

ModuleRegistry.registerModules([
  NumberFilterModule,
  ClientSideRowModelModule,
  ColumnsToolPanelModule,
  FiltersToolPanelModule,
  SetFilterModule,
  PivotModule,
  TextFilterModule,
]);

let gridApi: GridApi<IOlympicData>;

const gridOptions: GridOptions<IOlympicData> = {
  columnDefs: [
    { field: "athlete", filter: "agTextColumnFilter", minWidth: 200 },
    { field: "age" },
    { field: "country", minWidth: 180 },
    { field: "year" },
    { field: "date", minWidth: 150 },
    { field: "gold" },
    { field: "silver" },
    { field: "bronze" },
    { field: "total" },
  ],
  defaultColDef: {
    flex: 1,
    minWidth: 100,
    // allow every column to be aggregated
    enableValue: true,
    // allow every column to be grouped
    enableRowGroup: true,
    // allow every column to be pivoted
    enablePivot: true,
    filter: true,
  },
  sideBar: "filters",
};

const gridDiv = document.querySelector<HTMLElement>("#myGrid")!;
gridApi = createGrid(gridDiv, gridOptions);

fetch("https://www.ag-grid.com/example-assets/olympic-winners.json")
  .then((response) => response.json())
  .then((data: IOlympicData[]) => gridApi!.setGridOption("rowData", data));
```

[Live example: Side Bar - Only Filters](https://www.ag-grid.com/examples/side-bar/only-filters/typescript)

### SideBarDef Configuration

The previous configurations are shortcuts for the full fledged configuration using a `SideBarDef` object. For full control over the configuration, you must provide a `SideBarDef` object.

Properties available on the `SideBarDef` interface.

| Property | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `toolPanels` | `(ToolPanelDef \| string)[]` |  |  | A list of all the panels to place in the side bar. The panels will be displayed in the provided order from top to bottom. |
| `defaultToolPanel` | `string` |  |  | The panel (identified by ID) to open by default. If none specified, the side bar is initially displayed closed. |
| `hiddenByDefault` | `boolean` |  |  | To hide the side bar by default, set this to `true`. If left undefined the side bar will be shown. |
| `position` | `'left' \| 'right'` |  |  | Sets the side bar position relative to the grid. |
| `hideButtons` | `boolean` |  |  | To hide the side bar buttons by default set this to true. If left undefined the buttons will be shown. This is useful if you want to show a tool panel without showing the buttons. |

The `toolPanels` property follows the `ToolPanelDef` interface:

Properties available on the `ToolPanelDef` interface.

| Property | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `id` | `string` |  |  | The unique ID for this panel. Used in the API and elsewhere to refer to the panel. |
| `labelKey` | `string` |  |  | The key used for localisation for displaying the label. The label is displayed in the tab button. |
| `labelDefault` | `string` |  |  | The default label if `labelKey` is missing or does not map to valid text through localisation. |
| `minWidth` | `number` |  | `100` | The min width of the tool panel. |
| `maxWidth` | `number` |  |  | The max width of the tool panel. |
| `width` | `number` |  | `$side-bar-panel-width (theme variable)` | The initial width of the tool panel. |
| `iconKey` | `string` |  |  | The key of the icon to be used as a graphical aid beside the label in the side bar. |
| `toolPanel` | `any` |  |  | The tool panel component to use as the panel. The provided panels use components `agColumnsToolPanel`, `agFiltersToolPanel` and `agNewFiltersToolPanel`. To provide your own custom panel component, you reference it here. |
| `toolPanelParams` | `any` |  |  | Customise the parameters provided to the `toolPanel` component. |
| `parent` | [`HTMLElement \| null`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement) |  |  | DOM element to use as the parent for the tool panel to allow it to appear outside the grid. Set to `null` or omit the property for tool panel to appear inside the grid. |

The following snippet shows configuring the Tool Panel using a `SideBarDef` object:

```js
const gridOptions = {
    sideBar: {
        toolPanels: [
            {
                id: 'columns',
                labelDefault: 'Columns',
                labelKey: 'columns',
                iconKey: 'columns',
                toolPanel: 'agColumnsToolPanel',
                minWidth: 225,
                maxWidth: 225,
                width: 225
            },
            {
                id: 'filters',
                labelDefault: 'Filters',
                labelKey: 'filters',
                iconKey: 'filter',
                toolPanel: 'agFiltersToolPanel',
                minWidth: 180,
                maxWidth: 400,
                width: 250
            }
        ],
        position: 'left',
        defaultToolPanel: 'filters',
    },

    // other grid options ...
}
```

The snippet above is demonstrated in the following example:

#### SideBarDef

```ts
import {
  ClientSideRowModelModule,
  GridApi,
  GridOptions,
  ModuleRegistry,
  NumberFilterModule,
  TextFilterModule,
  createGrid,
  enableDevValidations,
} from "ag-grid-community";
import {
  ColumnsToolPanelModule,
  FiltersToolPanelModule,
  PivotModule,
  SetFilterModule,
} from "ag-grid-enterprise";
import { IOlympicData } from "./interfaces";

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

ModuleRegistry.registerModules([
  NumberFilterModule,
  ClientSideRowModelModule,
  ColumnsToolPanelModule,
  FiltersToolPanelModule,
  SetFilterModule,
  PivotModule,
  TextFilterModule,
]);

let gridApi: GridApi<IOlympicData>;

const gridOptions: GridOptions<IOlympicData> = {
  columnDefs: [
    { field: "athlete", filter: "agTextColumnFilter", minWidth: 200 },
    { field: "age" },
    { field: "country", minWidth: 180 },
    { field: "year" },
    { field: "date", minWidth: 150 },
    { field: "gold" },
    { field: "silver" },
    { field: "bronze" },
    { field: "total" },
  ],
  defaultColDef: {
    flex: 1,
    minWidth: 100,
    // allow every column to be aggregated
    enableValue: true,
    // allow every column to be grouped
    enableRowGroup: true,
    // allow every column to be pivoted
    enablePivot: true,
    filter: true,
  },
  autoGroupColumnDef: {
    minWidth: 200,
  },
  sideBar: {
    toolPanels: [
      {
        id: "columns",
        labelDefault: "Columns",
        labelKey: "columns",
        iconKey: "columns",
        toolPanel: "agColumnsToolPanel",
        minWidth: 225,
        width: 225,
        maxWidth: 225,
      },
      {
        id: "filters",
        labelDefault: "Filters",
        labelKey: "filters",
        iconKey: "filter",
        toolPanel: "agFiltersToolPanel",
        minWidth: 180,
        maxWidth: 400,
        width: 250,
      },
    ],
    position: "left",
    defaultToolPanel: "filters",
  },
};

const gridDiv = document.querySelector<HTMLElement>("#myGrid")!;
gridApi = createGrid(gridDiv, gridOptions);

fetch("https://www.ag-grid.com/example-assets/olympic-winners.json")
  .then((response) => response.json())
  .then((data: IOlympicData[]) => gridApi!.setGridOption("rowData", data));
```

[Live example: SideBarDef](https://www.ag-grid.com/examples/side-bar/sideBarDef/typescript)

> **Note**
>
> Calling `setSideBarVisible(true)` when `sideBarDef.hideButtons` is set to true and no tool panel is open will not display anything.

> **Note**
>
> The [Popup Parent](https://www.ag-grid.com/javascript-data-grid/context-menu/#popup-parent) must be set to an element that contains both the tool panel parent and the grid to ensure all popups (e.g., Columns Tool Panel context menus) are fully visible.

## Configuration Shortcuts

The `boolean` and `string` configurations are shortcuts for more detailed configurations. When you use a shortcut the grid replaces it with the equivalent long form of the configuration by building the equivalent `SideBarDef`.

The following code snippets show an example of the `boolean` shortcut and the equivalent `SideBarDef` long form.

```js
const gridOptions = {
    // shortcut
    sideBar: true,

    // other grid options ...
}
```

```js
const gridOptions = {
    // equivalent detailed long form
    sideBar: {
        toolPanels: [
            {
                id: 'columns',
                labelDefault: 'Columns',
                labelKey: 'columns',
                iconKey: 'columns',
                toolPanel: 'agColumnsToolPanel',
            },
            {
                id: 'filters',
                labelDefault: 'Filters',
                labelKey: 'filters',
                iconKey: 'filter',
                toolPanel: 'agFiltersToolPanel',
            }
        ],
        defaultToolPanel: 'columns',
    },

    // other grid options ...
}
```

The following code snippets show an example of the `string` shortcut and the equivalent `SideBarDef` long form.

```js
const gridOptions = {
    // shortcut
    sideBar: 'filters',

    // other grid options ...
}
```

```js
const gridOptions = {
    // equivalent detailed long form
    sideBar: {
        toolPanels: [
            {
                id: 'filters',
                labelDefault: 'Filters',
                labelKey: 'filters',
                iconKey: 'filter',
                toolPanel: 'agFiltersToolPanel',
            }
        ],
        defaultToolPanel: 'filters',
    },

    // other grid options ...
}
```

You can also use shortcuts inside the `sideBar.toolPanels` array for specifying the Columns and Filters items.

```js
const gridOptions = {
    // shortcut
    sideBar: {
        toolPanels: ['columns', 'filters']
    },

    // other grid options ...
}
```

```js
const gridOptions = {
    // equivalent detailed long form
    sideBar: {
        toolPanels: [
            {
                id: 'columns',
                labelDefault: 'Columns',
                labelKey: 'columns',
                iconKey: 'columns',
                toolPanel: 'agColumnsToolPanel',
            },
            {
                id: 'filters',
                labelDefault: 'Filters',
                labelKey: 'filters',
                iconKey: 'filter',
                toolPanel: 'agFiltersToolPanel',
            }
        ]
    },

    // other grid options ...
}
```

## Side Bar Customisation

If you are using the long form (providing a `SideBarDef` object) then it is possible to customise. The example below changes the filter label and icon.

#### Side Bar Fine Tuning

```ts
import {
  ClientSideRowModelModule,
  GridApi,
  GridOptions,
  ModuleRegistry,
  NumberFilterModule,
  TextFilterModule,
  createGrid,
  enableDevValidations,
} from "ag-grid-community";
import {
  ColumnsToolPanelModule,
  FiltersToolPanelModule,
  PivotModule,
  SetFilterModule,
} from "ag-grid-enterprise";
import { IOlympicData } from "./interfaces";

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

ModuleRegistry.registerModules([
  NumberFilterModule,
  ClientSideRowModelModule,
  ColumnsToolPanelModule,
  FiltersToolPanelModule,
  SetFilterModule,
  PivotModule,
  TextFilterModule,
]);

let gridApi: GridApi<IOlympicData>;

const gridOptions: GridOptions<IOlympicData> = {
  columnDefs: [
    { field: "athlete", filter: "agTextColumnFilter", minWidth: 200 },
    { field: "age" },
    { field: "country", minWidth: 180 },
    { field: "year" },
    { field: "date", minWidth: 150 },
    { field: "gold" },
    { field: "silver" },
    { field: "bronze" },
    { field: "total" },
  ],
  defaultColDef: {
    flex: 1,
    minWidth: 100,
    // allow every column to be aggregated
    enableValue: true,
    // allow every column to be grouped
    enableRowGroup: true,
    // allow every column to be pivoted
    enablePivot: true,
    filter: true,
  },
  autoGroupColumnDef: {
    minWidth: 200,
  },
  sideBar: {
    toolPanels: [
      "columns",
      {
        id: "filters",
        labelKey: "filters",
        labelDefault: "Filters",
        iconKey: "menu",
        toolPanel: "agFiltersToolPanel",
      },
      {
        id: "filters 2",
        labelKey: "filters",
        labelDefault: "Filters XXXXXXXX",
        iconKey: "filter",
        toolPanel: "agFiltersToolPanel",
      },
    ],
    defaultToolPanel: "filters",
  },
};

const gridDiv = document.querySelector<HTMLElement>("#myGrid")!;
gridApi = createGrid(gridDiv, gridOptions);

fetch("https://www.ag-grid.com/example-assets/olympic-winners.json")
  .then((response) => response.json())
  .then((data: IOlympicData[]) => gridApi!.setGridOption("rowData", data));
```

[Live example: Side Bar Fine Tuning](https://www.ag-grid.com/examples/side-bar/fine-tuning/typescript)

### Tool Panel Parent

By default, Tool Panels are rendered inside the Side Bar. If you want to render Tool Panels in a different location, you can set the [parent](https://www.ag-grid.com/javascript-data-grid/side-bar#reference-ToolPanelDef-parent) property in the `ToolPanelDef`. This is useful if you want to render Tool Panel in a different part of your application, such as a popup window or a separate section of your page.

> **Note**
>
> To ensure correct panel sizing, AG Grid adds a CSS class to the parent element. If your component also sets the parent class it may overwrite this, so include the `ag-tool-panel-external` class when setting the parent class:
>
> ```html
> <div id="toolPanelParent" class="your-app-class ag-tool-panel-external"></div>
> ```

The [Popup Parent](https://www.ag-grid.com/javascript-data-grid/context-menu/#popup-parent) must also be set to an element that contains both the Tool Panel parent and the grid.

You can also provide a parent for the tool panel in the call to openToolPanel method:

| Property | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `openToolPanel` | `Function` |  |  | Opens a particular tool panel. Provide the ID of the tool panel to open. Optionally, provide a parent element to attach the tool panel to. Module: [`SideBarModule`](https://www.ag-grid.com/javascript-data-grid/modules/). |

#### Tool Panel Parent

```ts
import {
  ClientSideRowModelModule,
  GridApi,
  GridOptions,
  ModuleRegistry,
  NumberFilterModule,
  TextFilterModule,
  ToolPanelDef,
  createGrid,
  enableDevValidations,
} from "ag-grid-community";
import {
  ColumnsToolPanelModule,
  NewFiltersToolPanelModule,
  PivotModule,
  SetFilterModule,
} from "ag-grid-enterprise";
import { IOlympicData } from "./interfaces";

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

ModuleRegistry.registerModules([
  NumberFilterModule,
  ClientSideRowModelModule,
  ColumnsToolPanelModule,
  NewFiltersToolPanelModule,
  SetFilterModule,
  PivotModule,
  TextFilterModule,
]);

let gridApi: GridApi<IOlympicData>;
const columnsToolPanel: ToolPanelDef = {
  id: "columns",
  labelDefault: "Popup",
  labelKey: "columns",
  iconKey: "columnsToolPanel",
  toolPanel: "agColumnsToolPanel",
  toolPanelParams: {
    suppressRowGroups: true,
    suppressValues: true,
    suppressPivotMode: true,
  },
  parent: document.querySelector("#popup .content"),
};
const filtersToolPanel: ToolPanelDef = {
  id: "filters",
  labelDefault: "Drawer",
  labelKey: "filters",
  iconKey: "filter",
  toolPanel: "agNewFiltersToolPanel",
};

const gridOptions: GridOptions<IOlympicData> = {
  popupParent: document.body,
  columnDefs: [
    { field: "athlete", filter: "agTextColumnFilter", minWidth: 200 },
    { field: "country", minWidth: 180 },
    { field: "date", minWidth: 150 },
    { field: "gold", minWidth: 150 },
    { field: "silver", minWidth: 150 },
  ],
  enableFilterHandlers: true,
  defaultColDef: { flex: 1, minWidth: 100, filter: true },
  autoGroupColumnDef: { minWidth: 200 },
  sideBar: {
    toolPanels: [columnsToolPanel, filtersToolPanel],
    hideButtons: true,
    hiddenByDefault: true,
  },
};

function closePopup() {
  const drawer = document.getElementById("popup");
  drawer.classList.toggle("active", false);
  gridApi.closeToolPanel();
}

function closeDrawer() {
  const drawer = document.getElementById("drawer");
  drawer.classList.toggle("active", false);
  gridApi.closeToolPanel();
}

function openPopup() {
  closeDrawer();
  const popup = document.getElementById("popup")!;
  popup.classList.toggle("active", true);
  gridApi.openToolPanel(columnsToolPanel.id);
  addStyles(popup);
}

function openDrawer() {
  closePopup();
  const drawer = document.getElementById("drawer")!;
  drawer.classList.toggle("active", true);
  gridApi.openToolPanel(filtersToolPanel.id, drawer.querySelector(".content"));
  addStyles(drawer);
}

function addStyles(parentEl: HTMLElement) {
  const contentClassnames = [
    ...parentEl.querySelector(".content").classList,
  ].filter((e) => e !== "content");
  parentEl.classList.add(...contentClassnames);
}

const gridDiv = document.querySelector<HTMLElement>("#myGrid")!;
gridApi = createGrid(gridDiv, gridOptions);

fetch("https://www.ag-grid.com/example-assets/olympic-winners.json")
  .then((response) => response.json())
  .then((data: IOlympicData[]) => gridApi!.setGridOption("rowData", data));

if (typeof window !== "undefined") {
  // Attach external event handlers to window so they can be called from index.html
  (<any>window).closePopup = closePopup;
  (<any>window).closeDrawer = closeDrawer;
  (<any>window).openPopup = openPopup;
  (<any>window).openDrawer = openDrawer;
}
```

[Live example: Tool Panel Parent](https://www.ag-grid.com/examples/side-bar/tool-panel-parent/typescript)

## Providing Parameters to Tool Panels

Parameters are passed to Tool Panels via the `toolPanelParams` object. For example, the following code snippet sets `suppressRowGroups: true` and `suppressValues: true` for the [Columns Tool Panel](https://www.ag-grid.com/javascript-data-grid/tool-panel-columns/).

```js
const gridOptions = {
    sideBar: {
        toolPanels: [
            {
                id: 'columns',
                labelDefault: 'Columns',
                labelKey: 'columns',
                iconKey: 'columns',
                toolPanel: 'agColumnsToolPanel',
                toolPanelParams: {
                    suppressRowGroups: true,
                    suppressValues: true,
                }
            }
        ]
    },

    // other grid options ...
}
```

See the [Columns Tool Panel](https://www.ag-grid.com/javascript-data-grid/tool-panel-columns/) documentation for the full list of possible parameters to this Tool Panel.

## Animation

By default, sidebar panels open and close instantly. You can enable a smooth slide animation using the [Theming API](https://www.ag-grid.com/javascript-data-grid/theming-api/) parameter `sideBarPanelAnimationDuration`. Set it to a value in seconds:

```js
const myTheme = themeQuartz.withParams({
    sideBarPanelAnimationDuration: 0.3,
});
```

The animation is automatically disabled for users who have requested reduced motion in their OS accessibility settings.

#### Side Bar Animation

```ts
import {
  ClientSideRowModelModule,
  ColDef,
  GridApi,
  GridOptions,
  ModuleRegistry,
  NumberFilterModule,
  TextFilterModule,
  createGrid,
  enableDevValidations,
  themeQuartz,
} from "ag-grid-community";
import {
  ColumnsToolPanelModule,
  NewFiltersToolPanelModule,
  PivotModule,
  SideBarModule,
} from "ag-grid-enterprise";
import { IOlympicData } from "./interfaces";

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

ModuleRegistry.registerModules([
  ClientSideRowModelModule,
  ColumnsToolPanelModule,
  NewFiltersToolPanelModule,
  TextFilterModule,
  NumberFilterModule,
  SideBarModule,
  PivotModule,
]);

const myTheme = themeQuartz.withParams({
  sideBarPanelAnimationDuration: 0.3,
});

const columnDefs: ColDef[] = [
  { field: "athlete" },
  { field: "country" },
  { field: "sport" },
  { field: "year" },
];

let gridApi: GridApi<IOlympicData>;

const gridOptions: GridOptions<IOlympicData> = {
  theme: myTheme,
  columnDefs: columnDefs,
  defaultColDef: {
    flex: 1,
    filter: true,
    sortable: true,
    resizable: true,
  },
  enableFilterHandlers: true,
  sideBar: ["columns", "filters-new"],
};

const gridDiv = document.querySelector<HTMLElement>("#myGrid")!;
gridApi = createGrid(gridDiv, gridOptions);

fetch("https://www.ag-grid.com/example-assets/olympic-winners.json")
  .then((response) => response.json())
  .then((data: IOlympicData[]) => gridApi!.setGridOption("rowData", data));
```

[Live example: Side Bar Animation](https://www.ag-grid.com/examples/side-bar/animation/typescript)

## Side Bar API

> **Note**
>
> The Side Bar state can be saved and restored as part of [Grid State](https://www.ag-grid.com/javascript-data-grid/grid-state/).

The list below details all the API methods relevant to the Tool Panel.

| Property | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `getSideBar` | `Function` |  |  | Returns the current side bar configuration. If a shortcut was used, returns the detailed long form. Module: [`SideBarModule`](https://www.ag-grid.com/javascript-data-grid/modules/). |
| `setSideBarVisible` | `Function` |  |  | Show/hide the entire side bar, including any visible panel and the tab buttons. Module: [`SideBarModule`](https://www.ag-grid.com/javascript-data-grid/modules/). |
| `isSideBarVisible` | `Function` |  |  | Returns `true` if the side bar is visible. Module: [`SideBarModule`](https://www.ag-grid.com/javascript-data-grid/modules/). |
| `setSideBarPosition` | `Function` |  |  | Sets the side bar position relative to the grid. Possible values are `'left'` or `'right'`. Module: [`SideBarModule`](https://www.ag-grid.com/javascript-data-grid/modules/). |
| `openToolPanel` | `Function` |  |  | Opens a particular tool panel. Provide the ID of the tool panel to open. Optionally, provide a parent element to attach the tool panel to. Module: [`SideBarModule`](https://www.ag-grid.com/javascript-data-grid/modules/). |
| `closeToolPanel` | `Function` |  |  | Closes the currently open tool panel (if any). Module: [`SideBarModule`](https://www.ag-grid.com/javascript-data-grid/modules/). |
| `getOpenedToolPanel` | `Function` |  |  | Returns the ID of the currently shown tool panel if any, otherwise `null`. Module: [`SideBarModule`](https://www.ag-grid.com/javascript-data-grid/modules/). |
| `isToolPanelShowing` | `Function` |  |  | Returns `true` if the tool panel is showing, otherwise `false`. Module: [`SideBarModule`](https://www.ag-grid.com/javascript-data-grid/modules/). |
| `refreshToolPanel` | `Function` |  |  | Force refreshes all tool panels by calling their `refresh` method. Module: [`SideBarModule`](https://www.ag-grid.com/javascript-data-grid/modules/). |
| `getToolPanelInstance` | `Function` |  |  | Gets the tool panel instance corresponding to the supplied `id`. Module: [`SideBarModule`](https://www.ag-grid.com/javascript-data-grid/modules/). |

The example below demonstrates different usages of the Tool Panel API methods. The following can be noted:

- Initially the Side Bar is not visible as `sideBar.hiddenByDefault=true`.
- **Visibility Buttons:** These toggle visibility of the Tool Panel. Note that when you make `visible=false`, the entire Tool Panel is hidden including the tabs. Make sure the Tool Panel is left visible before testing the other API features so you can see the impact.
- **Open / Close Buttons:** These open and close different Tool Panel items.
- **Reset Buttons:** These reset the Tool Panel to a new configuration. Notice that [shortcuts](#configuration-shortcuts) are provided as configuration however `getSideBar()` returns back the long form.
- **Position Buttons:** These change the position of the Side Bar relative to the grid.
- The `get*` buttons log data to the developer console.

#### Side Bar API

```ts
import {
  ClientSideRowModelModule,
  GridApi,
  GridOptions,
  ModuleRegistry,
  NumberFilterModule,
  SideBarDef,
  TextFilterModule,
  ToolPanelSizeChangedEvent,
  ToolPanelVisibleChangedEvent,
  createGrid,
  enableDevValidations,
} from "ag-grid-community";
import {
  ColumnsToolPanelModule,
  FiltersToolPanelModule,
  PivotModule,
  SetFilterModule,
} from "ag-grid-enterprise";
import { IOlympicData } from "./interfaces";

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

ModuleRegistry.registerModules([
  NumberFilterModule,
  ClientSideRowModelModule,
  ColumnsToolPanelModule,
  FiltersToolPanelModule,
  SetFilterModule,
  PivotModule,
  TextFilterModule,
]);

let gridApi: GridApi<IOlympicData>;

const gridOptions: GridOptions<IOlympicData> = {
  columnDefs: [
    { field: "athlete", filter: "agTextColumnFilter", minWidth: 200 },
    { field: "age" },
    { field: "country", minWidth: 200 },
    { field: "year" },
    { field: "date", minWidth: 160 },
    { field: "gold" },
    { field: "silver" },
    { field: "bronze" },
    { field: "total" },
  ],
  defaultColDef: {
    flex: 1,
    minWidth: 100,
    // allow every column to be aggregated
    enableValue: true,
    // allow every column to be grouped
    enableRowGroup: true,
    // allow every column to be pivoted
    enablePivot: true,
    filter: true,
  },
  autoGroupColumnDef: {
    minWidth: 200,
  },
  sideBar: {
    toolPanels: [
      {
        id: "columns",
        labelDefault: "Columns",
        labelKey: "columns",
        iconKey: "columns",
        toolPanel: "agColumnsToolPanel",
      },
      {
        id: "filters",
        labelDefault: "Filters",
        labelKey: "filters",
        iconKey: "filter",
        toolPanel: "agFiltersToolPanel",
      },
    ],
    defaultToolPanel: "filters",
    hiddenByDefault: true,
  },
  onToolPanelVisibleChanged: (event: ToolPanelVisibleChangedEvent) => {
    console.log("toolPanelVisibleChanged", event);
  },
  onToolPanelSizeChanged: (event: ToolPanelSizeChangedEvent) => {
    console.log("toolPanelSizeChanged", event);
  },
};

function setSideBarVisible(value: boolean) {
  gridApi!.setSideBarVisible(value);
}

function isSideBarVisible() {
  console.log(gridApi!.isSideBarVisible());
}

function openToolPanel(key: string) {
  gridApi!.openToolPanel(key);
}

function closeToolPanel() {
  gridApi!.closeToolPanel();
}

function getOpenedToolPanel() {
  console.log(gridApi!.getOpenedToolPanel());
}

function setSideBar(def: SideBarDef | string | string[] | boolean) {
  gridApi!.setGridOption("sideBar", def);
}

function getSideBar() {
  const sideBar = gridApi!.getSideBar();
  console.log(JSON.stringify(sideBar));
  console.log(sideBar);
}

function setSideBarPosition(position: "left" | "right") {
  gridApi!.setSideBarPosition(position);
}

const gridDiv = document.querySelector<HTMLElement>("#myGrid")!;
gridApi = createGrid(gridDiv, gridOptions);

fetch("https://www.ag-grid.com/example-assets/olympic-winners.json")
  .then((response) => response.json())
  .then((data: IOlympicData[]) => gridApi!.setGridOption("rowData", data));

if (typeof window !== "undefined") {
  // Attach external event handlers to window so they can be called from index.html
  (<any>window).setSideBarVisible = setSideBarVisible;
  (<any>window).isSideBarVisible = isSideBarVisible;
  (<any>window).openToolPanel = openToolPanel;
  (<any>window).closeToolPanel = closeToolPanel;
  (<any>window).getOpenedToolPanel = getOpenedToolPanel;
  (<any>window).setSideBar = setSideBar;
  (<any>window).getSideBar = getSideBar;
  (<any>window).setSideBarPosition = setSideBarPosition;
}
```

[Live example: Side Bar API](https://www.ag-grid.com/examples/side-bar/api/typescript)
