---
product: "AG Studio"
title: "Configuring Widgets"
description: "The set of widgets available to report authors, and the configuration of each individual widget, can both be customised through the ."
framework: react
version: "3.0.0"
related:
    - title: "Widgets Overview"
      url: "https://www.ag-grid.com/studio/archive/3.0.0/react/widget-overview/"
    - title: "Custom Widgets"
      url: "https://www.ag-grid.com/studio/archive/3.0.0/react/custom-widgets/"
    - title: "Form Configuration"
      url: "https://www.ag-grid.com/studio/archive/3.0.0/react/custom-widgets-form/"
llms: "https://www.ag-grid.com/studio/archive/3.0.0/llms.txt"
---

# Configuring Widgets

The set of widgets available to report authors, and the configuration of each individual widget, can both be customised through the [`widgets` property](https://www.ag-grid.com/studio/archive/3.0.0/react/widget-overview/#widget-configuration-api).

## Available Widgets

#### Customise the Available Widgets

```tsx
"use client";

import React, {
  useCallback,
  useMemo,
  useRef,
  useState,
  StrictMode,
} from "react";
import { createRoot } from "react-dom/client";
import { AgStudio, AgStudioRef } from "ag-studio-react";
import {
  AgDataEngine,
  AgDataSourcesDefinition,
  AgDefaultRegistry,
  AgReportState,
  AgStudioApi,
  AgStudioApiReadyEvent,
  AgStudioMode,
  AgStudioProperties,
  AgWidgetsConfig,
  enableStudioDevValidations,
} from "ag-studio";
import { createWidgets } from "ag-studio-react";

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

const StudioExample = () => {
  const containerStyle = useMemo(() => ({ width: "100%", height: "100%" }), []);
  const studioStyle = useMemo(() => ({ height: "100%", width: "100%" }), []);
  const [data, setData] = useState<AgDataSourcesDefinition | AgDataEngine>();
  const initialState = useMemo<AgReportState>(() => {
    return {
      pages: [
        {
          id: "a",
          widgets: {
            "1": {
              type: "grid",
              dataMapping: {
                cols: [
                  { id: "medals.country" },
                  { id: "medals.sport" },
                  { id: "medals.gold", aggregation: "sum" },
                  { id: "medals.silver", aggregation: "sum" },
                  { id: "medals.bronze", aggregation: "sum" },
                  { id: "medals.total", aggregation: "sum" },
                ],
              },
            },
          },
          widgetLayout: {
            "1": {
              xTrack: 0,
              yTrack: 0,
              xSpan: 24,
              ySpan: 16,
            },
          },
        },
      ],
      selectedPageId: "a",
      panels: {
        filters: {
          collapsed: true,
        },
        data: {
          collapsed: true,
        },
      },
    };
  }, []);
  const widgets = useMemo<
    | AgWidgetsConfig
    | ((widgets: AgWidgetsConfig<AgDefaultRegistry>) => AgWidgetsConfig)
  >(() => {
    return (config: AgWidgetsConfig) =>
      createWidgets({
        menu: [
          {
            label: "Popular",
            widgetIds: ["grid", "value"],
          },
          {
            label: "Other",
            widgetIds: ["text", "button-filter"],
            collapsed: true,
          },
          config.menu[0],
        ],
        defaultType: "value",
      });
  }, []);

  const onApiReady = useCallback((params: AgStudioApiReadyEvent) => {
    fetch("https://www.ag-grid.com/studio/archive/3.0.0/example-assets/olympic-winners.json")
      .then((resp) => resp.json())
      .then((data: any[]) => setData({ sources: [{ id: "medals", data }] }));
  }, []);

  return (
    <div style={containerStyle}>
      <div style={{ display: "flex", flexDirection: "column", height: "100%" }}>
        <AgStudio
          style={studioStyle}
          className="my-studio-container"
          data={data}
          initialState={initialState}
          mode={"edit"}
          widgets={widgets}
          onApiReady={onApiReady}
        />
      </div>
    </div>
  );
};

const root = createRoot(document.getElementById("root")!);
root.render(
  <StrictMode>
    <StudioExample />
  </StrictMode>,
);
```

[Live example: Customise the Available Widgets](https://www.ag-grid.com/studio/archive/3.0.0/examples/widget-configuration/customise-available-widgets/reactFunctionalTs/)

The example above changes the list of available widgets to:

- Add new groups of widgets
- Show one of the groups collapsed by default
- Re-use one of the default widget groups
- Change the default widget type when dragging fields to the Value widget

```jsx
const widgets = createWidgets({
    menu: [
        // new menu configuration
    ],
    defaultType: 'value',
});

<AgStudio widgets={widgets} />
```

See the [Widget Configuration API](https://www.ag-grid.com/studio/archive/3.0.0/react/widget-overview/#widget-configuration-api) for details on the `createWidgets` helper function.

## Widget Overrides

#### Change the Configuration for Individual Widgets

```tsx
"use client";

import React, {
  useCallback,
  useMemo,
  useRef,
  useState,
  StrictMode,
} from "react";
import { createRoot } from "react-dom/client";
import { AgStudio, AgStudioRef } from "ag-studio-react";
import {
  AgBaseWidgetDefinition,
  AgDataEngine,
  AgDataSourcesDefinition,
  AgDefaultRegistry,
  AgFormTabGroup,
  AgGridWidget,
  AgPath,
  AgReportState,
  AgStudioApi,
  AgStudioApiReadyEvent,
  AgStudioMode,
  AgStudioProperties,
  AgWidgetsConfig,
  enableStudioDevValidations,
} from "ag-studio";
import { createWidgets } from "ag-studio-react";

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

const StudioExample = () => {
  const containerStyle = useMemo(() => ({ width: "100%", height: "100%" }), []);
  const studioStyle = useMemo(() => ({ height: "100%", width: "100%" }), []);
  const [data, setData] = useState<AgDataSourcesDefinition | AgDataEngine>();
  const initialState = useMemo<AgReportState>(() => {
    return {
      pages: [
        {
          id: "a",
          widgets: {
            "1": {
              type: "grid",
              dataMapping: {
                cols: [
                  { id: "medals.country" },
                  { id: "medals.sport" },
                  { id: "medals.gold", aggregation: "sum" },
                  { id: "medals.silver", aggregation: "sum" },
                  { id: "medals.bronze", aggregation: "sum" },
                  { id: "medals.total", aggregation: "sum" },
                ],
              },
            },
            "2": {
              type: "column-chart-grouped",
              dataMapping: {
                categoryKey: [{ id: "medals.country" }],
                valueKey: [
                  { id: "medals.gold", aggregation: "sum" },
                  { id: "medals.silver", aggregation: "sum" },
                  { id: "medals.bronze", aggregation: "sum" },
                ],
                tooltipKey: [],
              },
            },
          },
          widgetLayout: {
            "1": {
              xTrack: 0,
              yTrack: 0,
              xSpan: 24,
              ySpan: 16,
            },
            "2": {
              xTrack: 0,
              yTrack: 16,
              xSpan: 24,
              ySpan: 16,
            },
          },
          selection: {
            type: "widget",
            id: "1",
          },
        },
      ],
      selectedPageId: "a",
      panels: {
        filters: {
          collapsed: true,
        },
        data: {
          collapsed: true,
        },
      },
    };
  }, []);
  const widgets = useMemo<
    | AgWidgetsConfig
    | ((widgets: AgWidgetsConfig<AgDefaultRegistry>) => AgWidgetsConfig)
  >(() => {
    return (config: AgWidgetsConfig) => {
      const existingGridDef = config.widgets.find(
        ({ id }) => id === "grid",
      ) as AgBaseWidgetDefinition<"grid", AgGridWidget>;
      const newGridDef: Pick<
        AgBaseWidgetDefinition<"grid", AgGridWidget>,
        "id" | "label" | "form"
      > = {
        id: "grid",
        label: "Grid",
        form: (params) => {
          // update the grid form to remove the widget type selector
          const oldTabGroup = existingGridDef.form(params) as AgFormTabGroup<
            AgPath<AgGridWidget>
          >;
          const [oldSetupTab, oldFormatTab] = oldTabGroup.items;
          const newSetupTab = {
            ...oldSetupTab,
            items: [...oldSetupTab.items.slice(1), oldSetupTab.items[0]],
          };
          return {
            ...oldTabGroup,
            items: [newSetupTab, oldFormatTab],
          };
        },
      } as const;
      return createWidgets({
        overrides: [newGridDef],
      });
    };
  }, []);

  const onApiReady = useCallback((params: AgStudioApiReadyEvent) => {
    fetch("https://www.ag-grid.com/studio/archive/3.0.0/example-assets/olympic-winners.json")
      .then((resp) => resp.json())
      .then((data: any[]) => setData({ sources: [{ id: "medals", data }] }));
  }, []);

  return (
    <div style={containerStyle}>
      <div style={{ display: "flex", flexDirection: "column", height: "100%" }}>
        <AgStudio
          style={studioStyle}
          className="my-studio-container"
          data={data}
          initialState={initialState}
          mode={"edit"}
          widgets={widgets}
          onApiReady={onApiReady}
        />
      </div>
    </div>
  );
};

const root = createRoot(document.getElementById("root")!);
root.render(
  <StrictMode>
    <StudioExample />
  </StrictMode>,
);
```

[Live example: Change the Configuration for Individual Widgets](https://www.ag-grid.com/studio/archive/3.0.0/examples/widget-configuration/configure-individual-widgets/reactFunctionalTs/)

The example above changes the configuration for the Table widget to update the label from 'Table' to 'Grid', and move the widget selection input to the bottom of the setup tab.

```jsx
const widgets = createWidgets({
    overrides: [
        {
            id: 'grid',
            label: 'Grid',
            // ... other overrides
        }
    ]
});

<AgStudio widgets={widgets} />
```

Updating the `form` property for a widget allows the items in the Edit Panel to be customised, including changing their default values. See [Form Configuration](https://www.ag-grid.com/studio/archive/3.0.0/react/custom-widgets-form/) for more details.

## Pre-Configured Widgets

#### Pre-Configured Widgets

```tsx
"use client";

import React, {
  useCallback,
  useMemo,
  useRef,
  useState,
  StrictMode,
} from "react";
import { createRoot } from "react-dom/client";
import { AgStudio, AgStudioRef } from "ag-studio-react";
import {
  AgBaseRegistry,
  AgBaseWidgetDefinition,
  AgColumnChartGrouped,
  AgDataEngine,
  AgDataSourcesDefinition,
  AgDefaultRegistry,
  AgReportState,
  AgSortConfig,
  AgStudioApi,
  AgStudioApiReadyEvent,
  AgStudioMode,
  AgStudioProperties,
  AgWidgetFieldReference,
  AgWidgetsConfig,
  enableStudioDevValidations,
} from "ag-studio";
import { createWidgets } from "ag-studio-react";

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

interface CustomColumnChart<TType extends string> extends Omit<
  AgColumnChartGrouped,
  "type"
> {
  type: TType;
}
interface MyRegistry extends AgBaseRegistry {
  widgets: readonly (
    | CustomDef1
    | CustomDef2
    | AgBaseWidgetDefinition<"column-chart-grouped", AgColumnChartGrouped>
  )[];
}

const StudioExample = () => {
  const containerStyle = useMemo(() => ({ width: "100%", height: "100%" }), []);
  const studioStyle = useMemo(() => ({ height: "100%", width: "100%" }), []);
  const [data, setData] = useState<AgDataSourcesDefinition | AgDataEngine>();
  const initialState = useMemo<AgReportState<MyRegistry>>(() => {
    return {
      pages: [
        {
          id: "a",
        },
      ],
      selectedPageId: "a",
      panels: {
        filters: {
          collapsed: true,
        },
        data: {
          collapsed: true,
        },
      },
    };
  }, []);
  const widgets = useMemo<
    | AgWidgetsConfig<MyRegistry>
    | ((
        widgets: AgWidgetsConfig<AgDefaultRegistry>,
      ) => AgWidgetsConfig<MyRegistry>)
  >(() => {
    return (config: AgWidgetsConfig<AgDefaultRegistry>) => {
      const existingColumnChartDef = config.widgets.find(
        ({ id }) => id === "column-chart-grouped",
      ) as AgBaseWidgetDefinition<"column-chart-grouped", AgColumnChartGrouped>;
      // only show the widget type selector
      const form: CustomDef1["form"] = (params) => ({
        type: "tab-group",
        key: "config",
        items: [
          {
            type: "tab",
            key: "setup",
            label: "widgetFormSectionSetup",
            items: [params.createWidgetSection()],
          },
        ],
      });
      const def1: CustomDef1 = {
        ...existingColumnChartDef,
        id: "pre-configured-column-chart-1",
        label: "Gold Chart",
        defaultState: {
          dataMapping: {
            categoryKey: [{ id: "medals.country" }],
            valueKey: [
              {
                id: "medals.gold",
                aggregation: "sum",
              },
            ],
          },
          sort: [
            {
              field: { id: "medals.gold", aggregation: "sum" },
              direction: "desc",
            },
          ],
          format: {
            title: {
              enabled: true,
              text: "Gold Medals by Country",
            },
          },
        },
        form,
        formatShape: undefined,
        extends: "column-chart-grouped",
      };
      const def2: CustomDef2 = {
        ...existingColumnChartDef,
        id: "pre-configured-column-chart-2",
        label: "Silver Chart",
        defaultState: {
          dataMapping: {
            categoryKey: [{ id: "medals.country" }],
            valueKey: [
              {
                id: "medals.silver",
                aggregation: "sum",
              },
            ],
          },
          sort: [
            {
              field: { id: "medals.silver", aggregation: "sum" },
              direction: "desc",
            },
          ],
          format: {
            title: {
              enabled: true,
              text: "Silver Medals by Country",
            },
          },
        },
        form,
        formatShape: undefined,
        extends: "column-chart-grouped",
      };
      return createWidgets<MyRegistry>({
        menu: [
          {
            label: "Pre-Configured",
            widgetIds: [
              "pre-configured-column-chart-1",
              "pre-configured-column-chart-2",
            ],
          },
          {
            label: "Existing",
            widgetIds: ["column-chart-grouped"],
          },
        ],
        additionalTypes: [def1, def2],
      });
    };
  }, []);

  const onApiReady = useCallback((params: AgStudioApiReadyEvent) => {
    fetch("https://www.ag-grid.com/studio/archive/3.0.0/example-assets/olympic-winners.json")
      .then((resp) => resp.json())
      .then((data: any[]) => setData({ sources: [{ id: "medals", data }] }));
  }, []);

  return (
    <div style={containerStyle}>
      <div style={{ display: "flex", flexDirection: "column", height: "100%" }}>
        <AgStudio<MyRegistry>
          style={studioStyle}
          className="my-studio-container"
          data={data}
          initialState={initialState}
          widgets={widgets}
          mode={"edit"}
          onApiReady={onApiReady}
        />
      </div>
    </div>
  );
};

const root = createRoot(document.getElementById("root")!);
root.render(
  <StrictMode>
    <StudioExample />
  </StrictMode>,
);
```

[Live example: Pre-Configured Widgets](https://www.ag-grid.com/studio/archive/3.0.0/examples/widget-configuration/preconfigured-widgets/reactFunctionalTs/)

The example above updates the widget configuration to have two pre-configured widgets. These re-use the existing grouped column chart widgets, but set the fields and title, and hide all of the form options except for the widget selection input.

The pre-configured widgets are set up in a similar way to [Creating a Custom Widget](https://www.ag-grid.com/studio/archive/3.0.0/react/custom-widgets/#creating-a-custom-widget), but they copy the existing grouped column chart widget definition.

The `extends` property is set to `'column-chart-grouped'` so that all of the default values are set correctly, and the `defaultState` property is set with the desired data mapping, sort and title details.

## Cell Renderers

Table and pivot table widgets can render their cells with your own components, using AG Grid cell renderers.

#### Custom Cell Renderers

```tsx
"use client";

import React, {
  useCallback,
  useMemo,
  useRef,
  useState,
  StrictMode,
} from "react";
import { createRoot } from "react-dom/client";
import { AgStudio, AgStudioRef } from "ag-studio-react";
import {
  AgDataEngine,
  AgDataSourcesDefinition,
  AgDefaultRegistry,
  AgFieldDefinition,
  AgGridWidgetOptions,
  AgPivotGridWidgetOptions,
  AgReportState,
  AgStudioApi,
  AgStudioApiReadyEvent,
  AgStudioMode,
  AgStudioProperties,
  AgWidgetField,
  AgWidgetsConfig,
  enableStudioDevValidations,
} from "ag-studio";
import { createWidgets } from "ag-studio-react";
import CountryFlagCellRenderer from "./countryFlagCellRenderer.tsx";
import GoldCellRenderer from "./goldCellRenderer.tsx";
import OlympicSeasonCellRenderer from "./olympicSeasonCellRenderer.tsx";

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

// The shipped flag assets cover 20 of the 110 countries in the data, so the pivot widget is
// filtered to those countries to keep every visible row's flag resolvable.
const COUNTRIES_WITH_FLAGS = [
  "United States",
  "Germany",
  "Great Britain",
  "France",
  "Italy",
  "Netherlands",
  "Spain",
  "Sweden",
  "Norway",
  "Argentina",
  "Brazil",
  "Belgium",
  "Greece",
  "Ireland",
  "Iceland",
  "Portugal",
  "Denmark",
  "Colombia",
  "Uruguay",
  "Venezuela",
];

const fields: AgFieldDefinition[] = [
  {
    id: "country",
    name: "Country",
    format: "textFormat",
    context: { cellRenderer: "countryFlag" },
  },
  {
    id: "sport",
    name: "Sport",
    format: "textFormat",
  },
  {
    id: "year",
    name: "Year",
    format: "integerFormat",
    formatOptions: { format: "0" },
    context: { cellRenderer: "olympicSeason" },
  },
  {
    id: "gold",
    name: "Gold",
    format: "integerFormat",
    context: { cellRenderer: "gold" },
  },
  {
    id: "silver",
    name: "Silver",
    format: "integerFormat",
  },
  {
    id: "bronze",
    name: "Bronze",
    format: "integerFormat",
  },
];

const gridWidgetOptions: AgGridWidgetOptions = {
  createCellRenderer: (field: AgWidgetField) =>
    field.context?.cellRenderer === "gold" ? GoldCellRenderer : undefined,
};

const pivotGridWidgetOptions: AgPivotGridWidgetOptions = {
  createCellRenderer: (field: AgWidgetField) => {
    switch (field.context?.cellRenderer) {
      case "countryFlag":
        return CountryFlagCellRenderer;
      case "olympicSeason":
        return OlympicSeasonCellRenderer;
      case "gold":
        return GoldCellRenderer;
      default:
        return undefined;
    }
  },
};

const StudioExample = () => {
  const containerStyle = useMemo(() => ({ width: "100%", height: "100%" }), []);
  const studioStyle = useMemo(() => ({ height: "100%", width: "100%" }), []);
  const [data, setData] = useState<AgDataSourcesDefinition | AgDataEngine>();
  const initialState = useMemo<AgReportState>(() => {
    return {
      pages: [
        {
          id: "a",
          widgets: {
            "1": {
              type: "grid",
              dataMapping: {
                cols: [
                  { id: "medals.country" },
                  { id: "medals.sport" },
                  { id: "medals.gold", aggregation: "sum" },
                  { id: "medals.silver", aggregation: "sum" },
                  { id: "medals.bronze", aggregation: "sum" },
                ],
              },
              format: { title: { enabled: true, text: "Medals by Sport" } },
            },
            "2": {
              type: "pivot-grid",
              dataMapping: {
                rows: [{ id: "medals.country" }, { id: "medals.year" }],
                // Left empty so the values stay flat columns and the row groups render expanded.
                columns: [],
                values: [
                  { id: "medals.gold", aggregation: "sum" },
                  { id: "medals.silver", aggregation: "sum" },
                  { id: "medals.bronze", aggregation: "sum" },
                ],
              },
              format: {
                title: { enabled: true, text: "Medals by Country and Year" },
              },
            },
          },
          widgetLayout: {
            "1": { xTrack: 0, yTrack: 0, xSpan: 24, ySpan: 16 },
            "2": { xTrack: 0, yTrack: 16, xSpan: 24, ySpan: 16 },
          },
          filter: {
            widget: {
              "2": [
                {
                  field: { id: "medals.country" },
                  model: { operator: "isIn", value: COUNTRIES_WITH_FLAGS },
                },
              ],
            },
          },
        },
      ],
      selectedPageId: "a",
      panels: {
        filters: {
          collapsed: true,
        },
        data: {
          collapsed: true,
        },
      },
    };
  }, []);
  const widgets = useMemo<
    | AgWidgetsConfig
    | ((widgets: AgWidgetsConfig<AgDefaultRegistry>) => AgWidgetsConfig)
  >(() => {
    return createWidgets({
      overrides: [
        {
          id: "grid",
          options: gridWidgetOptions,
        },
        {
          id: "pivot-grid",
          options: pivotGridWidgetOptions,
        },
      ],
    });
  }, []);

  const onApiReady = useCallback((params: AgStudioApiReadyEvent) => {
    fetch("https://www.ag-grid.com/studio/archive/3.0.0/example-assets/olympic-winners.json")
      .then((resp) => resp.json())
      .then((data: any[]) =>
        setData({
          sources: [{ id: "medals", name: "Medals", data, fields }],
        }),
      );
  }, []);

  return (
    <div style={containerStyle}>
      <div style={{ display: "flex", flexDirection: "column", height: "100%" }}>
        <AgStudio
          style={studioStyle}
          className="my-studio-container"
          data={data}
          initialState={initialState}
          widgets={widgets}
          mode={"edit"}
          onApiReady={onApiReady}
        />
      </div>
    </div>
  );
};

const root = createRoot(document.getElementById("root")!);
root.render(
  <StrictMode>
    <StudioExample />
  </StrictMode>,
);
```

[Live example: Custom Cell Renderers](https://www.ag-grid.com/studio/archive/3.0.0/examples/widget-configuration/custom-cell-renderers/reactFunctionalTs/)

The example above renders a gold circle next to each value in the 'Gold' column of both widgets, a flag next to each country and a weather icon next to each year on the pivot table widget's Row Labels axis.

A field or Format definition can carry a `context` property holding any data your application needs. The `createCellRenderer` option on the table and pivot table widgets receives each field and can return a cell renderer, or `undefined` to keep the default rendering.

On the pivot table widget the option also covers the fields on the Row Labels axis, with two differences worth knowing:

- A Row Labels renderer is rendered inside the row's group cell, alongside its expand control and indentation, rather than replacing the cell.
- A Row Labels renderer receives no field information in its cell renderer params, so a renderer that needs to know which field it is rendering should close over the field passed to the callback.

```ts
const fields = [
    // ... other fields
    { id: 'gold', context: { cellRenderer: 'gold' } },
    { id: 'country', context: { cellRenderer: 'countryFlag' } },
    { id: 'year', context: { cellRenderer: 'olympicSeason' } },
]
```

```jsx
const widgets = createWidgets({
    overrides: [
        {
            id: 'grid',
            options: {
                createCellRenderer: (field) =>
                    field.context != null && field.context.cellRenderer === 'gold'
                         ? GoldCellRenderer
                         : undefined,
            },
        },
        {
            id: 'pivot-grid',
            options: {
                createCellRenderer: (field) => {
                    switch (field.context != null ? field.context.cellRenderer : undefined) {
                        case 'countryFlag':
                            return CountryFlagCellRenderer;
                        case 'olympicSeason':
                            return OlympicSeasonCellRenderer;
                        case 'gold':
                            return GoldCellRenderer;
                        default:
                            return undefined;
                    }
                },
            },
        },
    ],
});

<AgStudio widgets={widgets} />
```

Refer to the [AG Grid Cell Component Documentation](https://www.ag-grid.com/javascript-data-grid/component-cell-renderer/) for more details on how to create custom cell renderers.

## Toolbar Actions

Each widget has a toolbar containing buttons that trigger various actions.

To customise the toolbar, follow the steps for [Widget Overrides](https://www.ag-grid.com/studio/archive/3.0.0/react/widget-configuration/#widget-overrides) and set the `toolbar` property.

The following actions are available by default:

| Action | ID | Widgets |
| --- | --- | --- |
| Duplicate widget | `'duplicate'` | All |
| Delete widget | `'delete'` | All |
| CSV export | `'export'` | Grid and chart widgets |
| Download as image | `'download'` | Chart widgets |

Actions can also be executed via the API method `performWidgetAction`.

| Property | Type | Default | Description |
| --- | --- | --- | --- |
| `performWidgetAction` | `Function` |  | Execute an action for a widget. Action can be one of the default actions (`'duplicate'` or `'delete'`), or an action specific to that widget. |

#### Widget Actions

```tsx
"use client";

import React, {
  useCallback,
  useMemo,
  useRef,
  useState,
  StrictMode,
} from "react";
import { createRoot } from "react-dom/client";
import { AgStudio, AgStudioRef } from "ag-studio-react";
import {
  AgDataEngine,
  AgDataSourcesDefinition,
  AgReportState,
  AgStudioApi,
  AgStudioApiReadyEvent,
  AgStudioMode,
  AgStudioProperties,
  enableStudioDevValidations,
} from "ag-studio";

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

const StudioExample = () => {
  const studioRef = useRef<AgStudioRef>(null);
  const containerStyle = useMemo(() => ({ width: "100%", height: "100%" }), []);
  const studioStyle = useMemo(() => ({ height: "100%", width: "100%" }), []);
  const [data, setData] = useState<AgDataSourcesDefinition | AgDataEngine>();
  const initialState = useMemo<AgReportState>(() => {
    return {
      pages: [
        {
          id: "a",
          widgets: {
            "1": {
              type: "grid",
              dataMapping: {
                cols: [
                  { id: "medals.country" },
                  { id: "medals.sport" },
                  { id: "medals.gold", aggregation: "sum" },
                  { id: "medals.silver", aggregation: "sum" },
                  { id: "medals.bronze", aggregation: "sum" },
                  { id: "medals.total", aggregation: "sum" },
                ],
              },
              format: {
                title: {
                  text: "Medals by Country and Sport",
                },
              },
            },
            "2": {
              type: "column-chart-grouped",
              dataMapping: {
                categoryKey: [{ id: "medals.country" }],
                valueKey: [
                  { id: "medals.gold", aggregation: "sum" },
                  { id: "medals.silver", aggregation: "sum" },
                  { id: "medals.bronze", aggregation: "sum" },
                ],
                tooltipKey: [],
              },
            },
          },
          widgetLayout: {
            "1": {
              xTrack: 0,
              yTrack: 0,
              xSpan: 24,
              ySpan: 16,
            },
            "2": {
              xTrack: 0,
              yTrack: 16,
              xSpan: 24,
              ySpan: 16,
            },
          },
        },
      ],
      selectedPageId: "a",
      panels: {
        filters: {
          collapsed: true,
        },
        data: {
          collapsed: true,
        },
        edit: {
          collapsed: true,
        },
      },
    };
  }, []);

  const onApiReady = useCallback((params: AgStudioApiReadyEvent) => {
    fetch("https://www.ag-grid.com/studio/archive/3.0.0/example-assets/olympic-winners.json")
      .then((resp) => resp.json())
      .then((data: any[]) => setData({ sources: [{ id: "medals", data }] }));
  }, []);

  const exportWidget = useCallback(() => {
    studioRef.current!.api.performWidgetAction("1", "export");
  }, []);

  return (
    <div style={containerStyle}>
      <div style={{ display: "flex", flexDirection: "column", height: "100%" }}>
        <div className="example-controls">
          <div className="controls-row">
            <button onClick={exportWidget}>Export Widget to CSV</button>
          </div>
        </div>

        <AgStudio
          ref={studioRef}
          style={studioStyle}
          className="my-studio-container"
          data={data}
          initialState={initialState}
          mode={"edit"}
          onApiReady={onApiReady}
        />
      </div>
    </div>
  );
};

const root = createRoot(document.getElementById("root")!);
root.render(
  <StrictMode>
    <StudioExample />
  </StrictMode>,
);
```

[Live example: Widget Actions](https://www.ag-grid.com/studio/archive/3.0.0/examples/widget-configuration/widget-actions/reactFunctionalTs/)

The example above demonstrates exporting data for the first widget via the API when the button is clicked.

### CSV Export

When performing CSV export, values are formatted the same way as in the widget.

By default, exports are limited to **1,000 rows** by applying a limit on the related query. Set `maxExportRows` on `dataOptions` to change this.

```jsx
const dataOptions = {
    maxExportRows: 5000,
};

<AgStudio dataOptions={dataOptions} />
```

> **Warning**
>
> `maxExportRows` supports `-1` for unlimited exports. Depending on the size of your data, you may get unexpected or undesired results, including but not limited to: memory, bandwidth or resource exhaustion.
