# Styling Editable, Read-Only & Edited Cells

Canonical page: https://www.adaptabletools.com/docs/ui-tutorial-editable-styles

- AdapTable allows developers to specify which cells in AG Grid are editable or read-only
- Use **`userInterfaceOptions`** — `editableCellStyle`, `readOnlyCellStyle`, `editedCellStyle` — each an [Adaptable Style](https://www.adaptabletools.com/docs/ui-tutorial-providing-adaptable-style/index.md) object

## Topics on this Page

| Topic                                       | Summary                     |
| ------------------------------------------- | --------------------------- |
| [Editable cells](#styling-editable-cells)   | `editableCellStyle`         |
| [Read-only cells](#styling-read-only-cells) | `readOnlyCellStyle`         |
| [Edited cells](#styling-edited-cells)       | `editedCellStyle` and demos |

[UI Guides](https://www.adaptabletools.com/docs/ui-tutorial-overview/index.md) · [User Interface Technical Reference](https://www.adaptabletools.com/docs/technical-reference-ui/index.md).

You might wish to visually indicate to your users which Cells in AG Grid are editable or read-only.

This is particularly the case if editability is set at the Grid Cell, rather than Column, level.

- See [Pre Edit Validation](https://www.adaptabletools.com/docs/handbook-validating-pre-edit/index.md) for instructions on using [isCellEditable](https://www.adaptabletools.com/docs/handbook-validating-pre-edit/index.md#setting-editable-cells) function in [Edit Options](https://www.adaptabletools.com/docs/technical-reference-editing/index.md) to set cell level editability
- This takes precedence over `ColDef.editable` in Grid Options - see [Setting Cell Editability Tutorial](https://www.adaptabletools.com/docs/dev-guide-tutorial-setting-cell-editability/index.md) for more details

Additionally you might want to show which cells have been edited (with an option to undo the edit).

Styling can be provided via 3 parallel functions in [User Interface Options](https://www.adaptabletools.com/docs/technical-reference-ui/index.md):

Typically users will provide one, but not both, of the first 2 functions

- `editableCellStyle` sets the style for editable cells
- `readOnlyCellStyle` sets the style for readonly cells
- `editedCellStyle` sets the style for edited cells

All 3 functions use the commonly used [Adaptable Style](https://www.adaptabletools.com/docs/ui-tutorial-providing-adaptable-style/index.md) object which can style a Cell in many ways.

## Styling Editable Cells

Use the `editableCellStyle` property to set a Style for all editable Cells in the Grid.

### `editableCellStyle`

Adaptable Style to apply to Editable Cells

  [`AdapTableStyle`](https://www.adaptabletools.com/docs/reference/adaptablestyle.md)

You can apply a style to Cells which are deemed to be Editable.

The style is of type [`Adaptable Style`](https://www.adaptabletools.com/docs/reference/adaptablestyle.md) - an object used in many places to create a Cell style:

| Property | Type | Description |
| --- | --- | --- |
| [ClassName](https://www.adaptabletools.com/docs/reference/adaptablestyle.md#classname) | `string` | CSS class added to the cell. Colour, font and border properties on this object are still applied. |

```ts {4,5,6,7}
// Set Editable Cells to be gray and italicised
const adaptableOptions: AdaptableOptions = {
    userInterfaceOptions: {
        editableCellStyle: {
          FontStyle: 'Italic',
          ForeColor: 'var(--ab-color-palette-16)',
        },
     ],
   }
}
```

**Example: Styling Editable Cells**

Styling the Editable Grid Cells in AdapTable

- In this example we provide an `editableCellStyle` (in [User Interface Options](https://www.adaptabletools.com/docs/technical-reference-ui/index.md)) of a yellow border with a radius so that editable cells to be readily identified
- We also provide 3 Editable cell Rules - set using `isCellEditable` property in [Edit Options](https://www.adaptabletools.com/docs/technical-reference-editing/index.md):
  - All cells in a row where `Language` cell value is _HTML_ are editable
  - `GitHub Watchers` is editable for cells with a value over 1,000
  - `Issue Change` is always editable
### Expand to see the Adaptable Options code

The Cell Editable Rules are created in Edit Options:
```ts
editOptions: {
  isCellEditable: (cellEditableContext: CellEditableContext) => {
    const gridCell: GridCell = cellEditableContext.gridCell;
    if (!gridCell || !gridCell.column) {
      return false;
    }
    // Editable where 'Language' is 'HTML'
    if (gridCell.rowNode.data['language'] === 'HTML') {
      return true;
    }
    // Github Watchers editable if > 1000
    if (gridCell.column.columnId === 'github_watchers') {
      if (gridCell.rawValue > 1000) {
        return true;
      }
    }
    // Week Issue Change always Editable
    if (gridCell.column.columnId === 'week_issue_change') {
      return true;
    }
    return false;
  },
},
```
And the style is created in User Interface Options:
```ts
userInterfaceOptions: {
 editableCellStyle: {
    BorderColor: 'var(--ab-color-palette-22)',
    BorderRadius: 6,
  },
},
```

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  [template]
  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,
  CellEditableContext,
  GridCell,
} from '@adaptabletools/adaptable';
import {WebFramework} from './rowData';

export const adaptableOptions: AdaptableOptions<WebFramework> = {
  primaryKey: 'id',
  adaptableId: 'Styling Editable Cells',
  editOptions: {
    isCellEditable: (cellEditableContext: CellEditableContext) => {
      const gridCell: GridCell = cellEditableContext.gridCell;
      if (!gridCell || !gridCell.column) {
        return false;
      }
      // Editable where 'Language' is 'HTML'
      if (gridCell.rowNode.data['language'] === 'HTML') {
        return true;
      }

      // Github Watchers editable if > 1000
      if (gridCell.column.columnId === 'github_watchers') {
        if (gridCell.rawValue > 1000) {
          return true;
        }
      }

      // Week Issue Change always Editable
      if (gridCell.column.columnId === 'week_issue_change') {
        return true;
      }

      return cellEditableContext.defaultColDefEditableValue;
    },
  },
  userInterfaceOptions: {
    editableCellStyle: {
      BorderColor: 'var(--ab-color-palette-22)',
      BorderRadius: 6,
    },
  },
  initialState: {
    Theme: {CurrentTheme: 'dark'},
    Layout: {
      CurrentLayout: 'Standard Layout',
      Layouts: [
        {
          Name: 'Standard Layout',
          TableColumns: [
            'name',
            'language',
            'github_stars',
            'week_issue_change',
            'github_watchers',
            'created_at',
            'has_wiki',
            'updated_at',
            'pushed_at',
            'open_issues_count',
            'open_pr_count',
            'closed_pr_count',
            'has_projects',
            'has_pages',
          ],
          AutoSizeColumns: true,
        },
      ],
    },
  },
};
```

## Styling Read-Only Cells

Use the `readOnlyCellStyle` property to set a Style for all read-ony Cells in the Grid.

### How AdapTable asseses whether a Cell is Read-Only

AdapTable asseses whether a given Cell in AG Grid is ReadOnly in 2 stages:

1. Checks if the Column has `editable` set to _false_ when it is defined in AG Grid GridOptions.

If this column setting is _false_ then **all** cells in the Column are always ReadOnly

2. Invokes the (optional) [isCellEditable](https://www.adaptabletools.com/docs/technical-reference-editing/index.md) boolean function in Edit Options; the cell is ReadOnly if this returns _false_

### `readOnlyCellStyle`

Adaptable Style to apply to Read Only Cells

  [`AdapTableStyle`](https://www.adaptabletools.com/docs/reference/adaptablestyle.md)

You can apply a style to Cells which are deemed to be Read Only.

The style is of type [`Adaptable Style`](https://www.adaptabletools.com/docs/reference/adaptablestyle.md) - an object used in many places to create a Cell style:

| Property | Type | Description |
| --- | --- | --- |
| [ClassName](https://www.adaptabletools.com/docs/reference/adaptablestyle.md#classname) | `string` | CSS class added to the cell. Colour, font and border properties on this object are still applied. |

```ts {4,5,6}
// Set ReadOnly Cells to have a brown border
const adaptableOptions: AdaptableOptions = {
    userInterfaceOptions: {
        readOnlyCellStyle: {
          BorderColor: 'var(--ab-color-palette-17)',
        },
     ],
   }
}
```

**Example: Styling Read-Only Cells**

Styling the Read-Only Grid Cells in AdapTable

- In this example we provide a `readOnlyCellStyle` (in [User Interface Options](https://www.adaptabletools.com/docs/technical-reference-ui/index.md)) of a gray background so that read-only cells can be readily identified
- We provide 3 Read-only cell Rules - set using `isCellEditable` property in [Edit Options](https://www.adaptabletools.com/docs/technical-reference-editing/index.md) (same as in above example but inverted):
  - All cells in a row where `Language` cell value is _HTML_ are read-only
  - `GitHub Watchers` is read-only for cells with a value over 1,000
  - `Issue Change` is always read-only
### Expand to see the Adaptable Options code

The Cell Editable Rules are created in Edit Options:
```ts
editOptions: {
  isCellEditable: (cellEditableContext: CellEditableContext) => {
    const gridCell: GridCell = cellEditableContext.gridCell;
    if (!gridCell || !gridCell.column) {
      return false;
    }
    // Read-Only where 'Language' is 'HTML'
    if (gridCell.rowNode.data['language'] === 'HTML') {
      return false;
    }
    // Github Watchers read-only if > 1000
    if (gridCell.column.columnId === 'github_watchers') {
      if (gridCell.rawValue > 1000) {
        return false;
      }
    }
    // Week Issue Change always read-only
    if (gridCell.column.columnId === 'week_issue_change') {
      return false;
    }
    return true;
  },
},
```
And the style is created in User Interface Options:
```ts
userInterfaceOptions: {
  readOnlyCellStyle: {
   BackColor: 'var(--ab-color-palette-16)',
  },
},
```

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  [template]
  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,
  CellEditableContext,
  GridCell,
} from '@adaptabletools/adaptable';
import {WebFramework} from './rowData';

export const adaptableOptions: AdaptableOptions<WebFramework> = {
  primaryKey: 'id',
  adaptableId: 'Styling ReadOnly Cells',
  editOptions: {
    isCellEditable: (cellEditableContext: CellEditableContext) => {
      const gridCell: GridCell = cellEditableContext.gridCell;
      if (!gridCell || !gridCell.column) {
        return false;
      }
      // Read-Only where 'Language' is 'HTML'
      if (gridCell.rowNode.data['language'] === 'HTML') {
        return false;
      }

      // Github Watchers read-only if > 1000
      if (gridCell.column.columnId === 'github_watchers') {
        if (gridCell.rawValue > 1000) {
          return false;
        }
      }

      // Week Issue Change always read-only
      if (gridCell.column.columnId === 'week_issue_change') {
        return false;
      }

      return cellEditableContext.defaultColDefEditableValue;
    },
  },
  userInterfaceOptions: {
    readOnlyCellStyle: {
      BackColor: 'var(--ab-color-palette-16)',
    },
  },
  initialState: {
    Theme: {CurrentTheme: 'dark'},
    Layout: {
      CurrentLayout: 'Standard Layout',
      Layouts: [
        {
          Name: 'Standard Layout',
          TableColumns: [
            'name',
            'language',
            'github_stars',
            'week_issue_change',
            'github_watchers',
            'created_at',
            'has_wiki',
            'updated_at',
            'pushed_at',
            'open_issues_count',
            'open_pr_count',
            'closed_pr_count',
            'has_projects',
            'has_pages',
          ],
          AutoSizeColumns: true,
        },
      ],
    },
  },
};
```

## Styling Edited Cells

Use the `editedCellStyle` property to set a Style for all Cells in the Grid which have been edited.

AdapTable leverages [Data Change History](https://www.adaptabletools.com/docs/handbook-monitoring-data-change-history/index.md) to monitor which Cells have been edited, so ensure that is turned on

### `editedCellStyle`

Adaptable Style to apply to Edited Cells

  [`AdapTableStyle`](https://www.adaptabletools.com/docs/reference/adaptablestyle.md)

You can apply a style to Cells which have been edited in the current session (and placed in the [Data Change History](https://www.adaptabletools.com/docs/handbook-monitoring-data-change-history/index.md) Log).

```ts {4,5,6}
// Set Edited Cells to have a brown border
const adaptableOptions: AdaptableOptions = {
    userInterfaceOptions: {
        editedCellStyle: {
          BorderColor: 'var(--ab-color-palette-17)',
        },
     ],
   }
}
```

The style is of type [`Adaptable Style`](https://www.adaptabletools.com/docs/reference/adaptablestyle.md) - an object used in many places to create a Cell style:

| Property | Type | Description |
| --- | --- | --- |
| [ClassName](https://www.adaptabletools.com/docs/reference/adaptablestyle.md#classname) | `string` | CSS class added to the cell. Colour, font and border properties on this object are still applied. |

**Example: Styling Edited Cells**

Styling the Edited Grid Cells in AdapTable

- In this example we provide a `editedCellStyle` (in [User Interface Options](https://www.adaptabletools.com/docs/technical-reference-ui/index.md)) of a gray background so that edited cells can be readily identified
- We set [Data Change History](https://www.adaptabletools.com/docs/handbook-monitoring-data-change-history/index.md) to be active by default and programmatically edit 2 cells in the `Language` column
### Expand to see the code used

1. The Data Change Monitor is automatically turned on in order to ensure Edits are tracked by AdapTable:
```ts
dataChangeHistoryOptions: {
  activeByDefault: true,
},
```
2. The Edited Cell Style is created in User Interface Options:
```ts
userInterfaceOptions: {
  editedCellStyle: {
    BackColor: 'var(--ab-color-palette-16)',
    FontStyle: 'Italic'
  },
},
```

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,
  CustomContextMenuContext,
  UserContextMenuItem,
} from '@adaptabletools/adaptable';
import {WebFramework} from './rowData';

export const adaptableOptions: AdaptableOptions<WebFramework> = {
  primaryKey: 'id',
  adaptableId: 'Styling Edited Cells',
  dataChangeHistoryOptions: {
    activeByDefault: true,
  },
  userInterfaceOptions: {
    editedCellStyle: {
      BackColor: 'var(--ab-color-palette-16)',
      FontStyle: 'Italic',
    },
  },
  initialState: {
    Dashboard: {
      ModuleButtons: ['DataChangeHistory'],
    },
    Theme: {CurrentTheme: 'dark'},
    Layout: {
      CurrentLayout: 'Standard Layout',
      Layouts: [
        {
          Name: 'Standard Layout',
          TableColumns: [
            'name',
            'language',
            'github_stars',
            'week_issue_change',
            'github_watchers',
            'created_at',
            'has_wiki',
            'updated_at',
            'pushed_at',
            'open_issues_count',
            'open_pr_count',
            'closed_pr_count',
            'has_projects',
            'has_pages',
          ],
          AutoSizeColumns: true,
        },
      ],
    },
  },
};
```

**`src/onAdaptableReady.ts`**

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

export const onAdaptableReady = ({adaptableApi}: AdaptableReadyInfo) => {
  const firstNode = adaptableApi.gridApi.getFirstRowNode();
  if (firstNode) {
    const cellUpdateRequest: CellUpdateRequest = {
      columnId: 'language',
      newValue: 'Python',
      primaryKeyValue:
        adaptableApi.gridApi.getPrimaryKeyValueForRowNode(firstNode),
      rowNode: firstNode,
    };
    adaptableApi.gridApi.setCellValue(cellUpdateRequest);
  }
  const svelteNode = adaptableApi.gridApi.getRowNodeForPrimaryKey(74293321);
  if (svelteNode) {
    const cellUpdateRequest: CellUpdateRequest = {
      columnId: 'language',
      newValue: 'Go',
      primaryKeyValue:
        adaptableApi.gridApi.getPrimaryKeyValueForRowNode(svelteNode),
      rowNode: svelteNode,
    };
    adaptableApi.gridApi.setCellValue(cellUpdateRequest);
  }
};
```

The ['Undoing Data Edits' Blog Post](https://www.adaptabletools.com/blog/2026-02-04-spotting-undoing-ag-grid-cell-edits) illustrates adding a custom Context Menu Item to edited cells to undo the edit

### FAQ

**Editable vs read-only styling together?**
Typically provide one of `editableCellStyle` or `readOnlyCellStyle`, not both — use whichever matches how you define editability (see [Setting Cell Editability](https://www.adaptabletools.com/docs/dev-guide-tutorial-setting-cell-editability/index.md)).

**Do styles use theme variables?**
Yes — e.g. `var(--ab-color-palette-16)` in the edited-cell demo; see [Referencing Theme Variables](https://www.adaptabletools.com/docs/handbook-theming-referencing/index.md).
