---
title: "Number Cell Editor"
framework: react
version: "36.1.0"
---

# Number Cell Editor

Simple number editor that uses the standard HTML number `input`.

The Number Cell Editor allows users to enter numeric values and to modify them using the `↑` `↓` keys.

## Enabling Number Cell Editor

Edit any cell in the grid below to see the Number Cell Editor.

#### Number Editor

```tsx
"use client";

import React, {
  useCallback,
  useMemo,
  useRef,
  useState,
  StrictMode,
} from "react";
import { createRoot } from "react-dom/client";
import { AgGridReact, AgGridProvider } from "ag-grid-react";
import {
  ClientSideRowModelModule,
  ColDef,
  ColGroupDef,
  GridApi,
  GridOptions,
  INumberCellEditorParams,
  ModuleRegistry,
  NumberEditorModule,
  enableDevValidations,
} from "ag-grid-community";

if (process.env.NODE_ENV !== "production") {
  enableDevValidations();
}

const modules = [ClientSideRowModelModule, NumberEditorModule];

const data = Array.from(Array(20).keys()).map((val: any, index: number) => ({
  number: index,
}));

const GridExample = () => {
  const containerStyle = useMemo(() => ({ width: "100%", height: "100%" }), []);
  const gridStyle = useMemo(() => ({ height: "100%", width: "100%" }), []);
  const [rowData, setRowData] = useState<any[]>(data);
  const [columnDefs, setColumnDefs] = useState<ColDef[]>([
    {
      headerName: "Number Editor",
      field: "number",
      cellEditor: "agNumberCellEditor",
      cellEditorParams: {
        min: 0,
        max: 100,
      } as INumberCellEditorParams,
    },
  ]);
  const defaultColDef = useMemo<ColDef>(() => {
    return {
      width: 200,
      editable: true,
    };
  }, []);

  return (
    <AgGridProvider modules={modules}>
      <div style={containerStyle}>
        <div style={gridStyle}>
          <AgGridReact
            rowData={rowData}
            columnDefs={columnDefs}
            defaultColDef={defaultColDef}
          />
        </div>
      </div>
    </AgGridProvider>
  );
};

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

[Live example: Number Editor](https://www.ag-grid.com/examples/provided-cell-editors-number/number-editor/reactFunctionalTs)

Enabled with `agNumberCellEditor` and configured with `INumberCellEditorParams`.

```js
columnDefs: [
    {
        cellEditor: 'agNumberCellEditor',
        cellEditorParams: {
            min: 0,
            max: 100
        }
        // ...other props
    }
]
```

## Customisation

### Step and Precision

It is possible to configure the step and precision of the stepping behaviour that increments/decrements the cell value. Edit any cell in the grid below to see a customised stepping behaviour.

#### Number Editor with Changed Precision

```tsx
"use client";

import React, {
  useCallback,
  useMemo,
  useRef,
  useState,
  StrictMode,
} from "react";
import { createRoot } from "react-dom/client";
import { AgGridReact, AgGridProvider } from "ag-grid-react";
import {
  ClientSideRowModelModule,
  ColDef,
  ColGroupDef,
  GridApi,
  GridOptions,
  INumberCellEditorParams,
  ModuleRegistry,
  NumberEditorModule,
  enableDevValidations,
} from "ag-grid-community";

if (process.env.NODE_ENV !== "production") {
  enableDevValidations();
}

const modules = [ClientSideRowModelModule, NumberEditorModule];

const data = Array.from(Array(20).keys()).map((val: any, index: number) => ({
  number: index,
}));

const GridExample = () => {
  const containerStyle = useMemo(() => ({ width: "100%", height: "100%" }), []);
  const gridStyle = useMemo(() => ({ height: "100%", width: "100%" }), []);
  const [rowData, setRowData] = useState<any[]>(data);
  const [columnDefs, setColumnDefs] = useState<ColDef[]>([
    {
      headerName: "Number Editor",
      field: "number",
      cellEditor: "agNumberCellEditor",
      cellEditorParams: {
        precision: 2,
        step: 0.25,
        showStepperButtons: true,
      } as INumberCellEditorParams,
    },
  ]);
  const defaultColDef = useMemo<ColDef>(() => {
    return {
      width: 200,
      editable: true,
    };
  }, []);

  return (
    <AgGridProvider modules={modules}>
      <div style={containerStyle}>
        <div style={gridStyle}>
          <AgGridReact
            rowData={rowData}
            columnDefs={columnDefs}
            defaultColDef={defaultColDef}
          />
        </div>
      </div>
    </AgGridProvider>
  );
};

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

[Live example: Number Editor with Changed Precision](https://www.ag-grid.com/examples/provided-cell-editors-number/number-editor-step-and-precision/reactFunctionalTs)

The stepping behaviour to increment/decrement the numeric value can be customised using the properties below:

```js
columnDefs: [
    {
        cellEditor: 'agNumberCellEditor',
        cellEditorParams: {
            precision: 2,
            step: 0.25,
            showStepperButtons: true
        }
        // ...other props
    }
]
```

### Prevent Stepping

The stepping behaviour can be disabled. Edit any cell in the grid below to see this.

#### Number Editor with Prevent Stepping

```tsx
"use client";

import React, {
  useCallback,
  useMemo,
  useRef,
  useState,
  StrictMode,
} from "react";
import { createRoot } from "react-dom/client";
import { AgGridReact, AgGridProvider } from "ag-grid-react";
import {
  ClientSideRowModelModule,
  ColDef,
  ColGroupDef,
  GridApi,
  GridOptions,
  INumberCellEditorParams,
  ModuleRegistry,
  NumberEditorModule,
  enableDevValidations,
} from "ag-grid-community";

if (process.env.NODE_ENV !== "production") {
  enableDevValidations();
}

const modules = [ClientSideRowModelModule, NumberEditorModule];

const data = Array.from(Array(20).keys()).map((val: any, index: number) => ({
  number: index,
}));

const GridExample = () => {
  const containerStyle = useMemo(() => ({ width: "100%", height: "100%" }), []);
  const gridStyle = useMemo(() => ({ height: "100%", width: "100%" }), []);
  const [rowData, setRowData] = useState<any[]>(data);
  const [columnDefs, setColumnDefs] = useState<ColDef[]>([
    {
      headerName: "Number Editor",
      field: "number",
      cellEditor: "agNumberCellEditor",
      cellEditorParams: {
        preventStepping: true,
      } as INumberCellEditorParams,
    },
  ]);
  const defaultColDef = useMemo<ColDef>(() => {
    return {
      width: 200,
      editable: true,
    };
  }, []);

  return (
    <AgGridProvider modules={modules}>
      <div style={containerStyle}>
        <div style={gridStyle}>
          <AgGridReact
            rowData={rowData}
            columnDefs={columnDefs}
            defaultColDef={defaultColDef}
          />
        </div>
      </div>
    </AgGridProvider>
  );
};

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

[Live example: Number Editor with Prevent Stepping](https://www.ag-grid.com/examples/provided-cell-editors-number/number-editor-prevent-stepping/reactFunctionalTs)

The stepping behaviour to increment/decrement the numeric value can be disabled as shown below:

```js
columnDefs: [
    {
        cellEditor: 'agNumberCellEditor',
        cellEditorParams: {
            preventStepping: true
        }
        // ...other props
    }
]
```

## API Reference

Properties available on the `INumberCellEditorParams&lt;TData = any, TContext = any&gt;` interface.

| Property | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `min` | `number` |  |  | Min allowed value. |
| `max` | `number` |  |  | Max allowed value. |
| `precision` | `number` |  |  | Number of digits allowed after the decimal point. |
| `step` | `number` |  |  | Size of the value change when stepping up/down, starting from `min` or the initial value if provided. Step is also the difference between valid values. If the user-provided value isn't a multiple of the step value from the starting value, it will be considered invalid. Defaults to any value allowed. |
| `showStepperButtons` | `boolean` |  | `false` | Display stepper buttons in editor. Note: Does not work when `preventStepping` is `true`. |
| `preventStepping` | `boolean` |  | `false` | Set to `true` to prevent key up/down from stepping the field's value. |
