Skip to content

Read-only cells

Make specified cells read-only to protect them from unwanted changes but still allow navigation and copying of data.

Disable individual cells, entire columns, or entire rows to prevent user edits. Use readOnly on cells, columns, or the whole grid.

Overview

Disabling a cell makes the cell read-only or non-editable. Both have similar outcomes, with the following differences:

Read-only cell
readOnly: true
Non-editable cell
editor: false
Has an additional CSS class (htDimmed), unless you turn it off with readOnlyStylingHas no additional CSS class
Copy works, paste doesn’t workCopy-paste works
Drag-to-fill doesn’t workDrag-to-fill works
Can’t be changed by populateFromArray()Can be changed by populateFromArray()
A checkbox ignores clicks, but still looks activeA checkbox is rendered as disabled

Pick readOnly when the user must not change the value at all. Pick editor: false when you only want to take away the editor, and still accept values from pasting, drag-to-fill, or the API.

Make the grid read-only

To make the entire grid read-only, set readOnly to true as a top-level grid option.

JavaScript
import { HotTable } from '@handsontable/react-wrapper';
import { registerAllModules } from 'handsontable/registry';
// register Handsontable's modules
registerAllModules();
const data = [
{ name: 'Hydrogen', symbol: 'H', atomicNumber: 1, atomicMass: 1.008 },
{ name: 'Helium', symbol: 'He', atomicNumber: 2, atomicMass: 4.003 },
{ name: 'Lithium', symbol: 'Li', atomicNumber: 3, atomicMass: 6.94 },
{ name: 'Beryllium', symbol: 'Be', atomicNumber: 4, atomicMass: 9.012 },
{ name: 'Boron', symbol: 'B', atomicNumber: 5, atomicMass: 10.81 },
];
const ExampleComponent = () => {
return (
<HotTable
// licenseKey="your-license-key" // get a key at https://handsontable.com/pricing/
data={data}
height="auto"
colHeaders={['Name', 'Symbol', 'Atomic number', 'Atomic mass']}
autoWrapRow={true}
autoWrapCol={true}
readOnly={true}
/>
);
};
export default ExampleComponent;
TypeScript
import { HotTable } from '@handsontable/react-wrapper';
import { registerAllModules } from 'handsontable/registry';
// register Handsontable's modules
registerAllModules();
const data = [
{ name: 'Hydrogen', symbol: 'H', atomicNumber: 1, atomicMass: 1.008 },
{ name: 'Helium', symbol: 'He', atomicNumber: 2, atomicMass: 4.003 },
{ name: 'Lithium', symbol: 'Li', atomicNumber: 3, atomicMass: 6.94 },
{ name: 'Beryllium', symbol: 'Be', atomicNumber: 4, atomicMass: 9.012 },
{ name: 'Boron', symbol: 'B', atomicNumber: 5, atomicMass: 10.81 },
];
const ExampleComponent = () => {
return (
<HotTable
// licenseKey="your-license-key" // get a key at https://handsontable.com/pricing/
data={data}
height="auto"
colHeaders={['Name', 'Symbol', 'Atomic number', 'Atomic mass']}
autoWrapRow={true}
autoWrapCol={true}
readOnly={true}
/>
);
};
export default ExampleComponent;

Make a column read-only

To make a column read-only, declare it in the columns configuration option. The column remains available for keyboard navigation and copying data (Ctrl/Cmd+C), but editing and pasting are disabled. The example below also defines a custom renderer that dims the read-only column, giving the user a visual cue that its cells are read-only.

JavaScript
import { HotTable } from '@handsontable/react-wrapper';
import { registerAllModules } from 'handsontable/registry';
import { textRenderer } from 'handsontable/renderers/textRenderer';
// register Handsontable's modules
registerAllModules();
const dimmedTextRenderer = (instance, td, ...rest) => {
textRenderer(instance, td, ...rest);
td.style.opacity = '0.6';
};
const data = [
{ name: 'Hydrogen', symbol: 'H', atomicNumber: 1, atomicMass: 1.008 },
{ name: 'Helium', symbol: 'He', atomicNumber: 2, atomicMass: 4.003 },
{ name: 'Lithium', symbol: 'Li', atomicNumber: 3, atomicMass: 6.94 },
{ name: 'Beryllium', symbol: 'Be', atomicNumber: 4, atomicMass: 9.012 },
{ name: 'Boron', symbol: 'B', atomicNumber: 5, atomicMass: 10.81 },
];
const ExampleComponent = () => {
return (
<HotTable
// licenseKey="your-license-key" // get a key at https://handsontable.com/pricing/
data={data}
height="auto"
colHeaders={['Name', 'Symbol', 'Atomic number', 'Atomic mass']}
autoWrapRow={true}
autoWrapCol={true}
columns={[
{
data: 'name',
readOnly: true,
renderer: dimmedTextRenderer,
},
{
data: 'symbol',
},
{
data: 'atomicNumber',
},
{
data: 'atomicMass',
},
]}
/>
);
};
export default ExampleComponent;
TypeScript
import { HotTable } from '@handsontable/react-wrapper';
import { registerAllModules } from 'handsontable/registry';
import { BaseRenderer } from 'handsontable/renderers';
import { textRenderer } from 'handsontable/renderers/textRenderer';
// register Handsontable's modules
registerAllModules();
const dimmedTextRenderer: BaseRenderer = (instance, td, ...rest) => {
textRenderer(instance, td, ...rest);
td.style.opacity = '0.6';
};
const data = [
{ name: 'Hydrogen', symbol: 'H', atomicNumber: 1, atomicMass: 1.008 },
{ name: 'Helium', symbol: 'He', atomicNumber: 2, atomicMass: 4.003 },
{ name: 'Lithium', symbol: 'Li', atomicNumber: 3, atomicMass: 6.94 },
{ name: 'Beryllium', symbol: 'Be', atomicNumber: 4, atomicMass: 9.012 },
{ name: 'Boron', symbol: 'B', atomicNumber: 5, atomicMass: 10.81 },
];
const ExampleComponent = () => {
return (
<HotTable
// licenseKey="your-license-key" // get a key at https://handsontable.com/pricing/
data={data}
height="auto"
colHeaders={['Name', 'Symbol', 'Atomic number', 'Atomic mass']}
autoWrapRow={true}
autoWrapCol={true}
columns={[
{
data: 'name',
readOnly: true,
renderer: dimmedTextRenderer,
},
{
data: 'symbol',
},
{
data: 'atomicNumber',
},
{
data: 'atomicMass',
},
]}
/>
);
};
export default ExampleComponent;

Make a row read-only

To make an entire row read-only, use the cells function and set the readOnly property based on the row index, regardless of the column. The example below makes the second row (index 1) read-only.

JavaScript
import { useRef, useEffect } from 'react';
import { HotTable } from '@handsontable/react-wrapper';
import { registerAllModules } from 'handsontable/registry';
// register Handsontable's modules
registerAllModules();
const data = [
{ name: 'Hydrogen', symbol: 'H', atomicNumber: 1, atomicMass: 1.008 },
{ name: 'Helium', symbol: 'He', atomicNumber: 2, atomicMass: 4.003 },
{ name: 'Lithium', symbol: 'Li', atomicNumber: 3, atomicMass: 6.94 },
{ name: 'Beryllium', symbol: 'Be', atomicNumber: 4, atomicMass: 9.012 },
{ name: 'Boron', symbol: 'B', atomicNumber: 5, atomicMass: 10.81 },
];
const ExampleComponent = () => {
const hotRef = useRef(null);
useEffect(() => {
const hot = hotRef.current?.hotInstance;
hot?.updateSettings({
cells(row) {
return row === 1 ? { readOnly: true } : {};
},
});
});
return (
<HotTable
// licenseKey="your-license-key" // get a key at https://handsontable.com/pricing/
ref={hotRef}
data={data}
colHeaders={['Name', 'Symbol', 'Atomic number', 'Atomic mass']}
height="auto"
autoWrapRow={true}
autoWrapCol={true}
/>
);
};
export default ExampleComponent;
TypeScript
import { useRef, useEffect } from 'react';
import { HotTable, HotTableRef } from '@handsontable/react-wrapper';
import { registerAllModules } from 'handsontable/registry';
// register Handsontable's modules
registerAllModules();
const data = [
{ name: 'Hydrogen', symbol: 'H', atomicNumber: 1, atomicMass: 1.008 },
{ name: 'Helium', symbol: 'He', atomicNumber: 2, atomicMass: 4.003 },
{ name: 'Lithium', symbol: 'Li', atomicNumber: 3, atomicMass: 6.94 },
{ name: 'Beryllium', symbol: 'Be', atomicNumber: 4, atomicMass: 9.012 },
{ name: 'Boron', symbol: 'B', atomicNumber: 5, atomicMass: 10.81 },
];
const ExampleComponent = () => {
const hotRef = useRef<HotTableRef>(null);
useEffect(() => {
const hot = hotRef.current?.hotInstance;
hot?.updateSettings({
cells(row) {
return row === 1 ? { readOnly: true } : {};
},
});
});
return (
<HotTable
// licenseKey="your-license-key" // get a key at https://handsontable.com/pricing/
ref={hotRef}
data={data}
colHeaders={['Name', 'Symbol', 'Atomic number', 'Atomic mass']}
height="auto"
autoWrapRow={true}
autoWrapCol={true}
/>
);
};
export default ExampleComponent;

Make specific cells read-only

To make specific cells read-only, use the cells function to set the readOnly property conditionally. The example below makes cells that contain the word “Helium” read-only.

JavaScript
import { useRef, useEffect } from 'react';
import { HotTable } from '@handsontable/react-wrapper';
import { registerAllModules } from 'handsontable/registry';
// register Handsontable's modules
registerAllModules();
const data = [
{ name: 'Hydrogen', symbol: 'H', atomicNumber: 1, atomicMass: 1.008 },
{ name: 'Helium', symbol: 'He', atomicNumber: 2, atomicMass: 4.003 },
{ name: 'Lithium', symbol: 'Li', atomicNumber: 3, atomicMass: 6.94 },
{ name: 'Beryllium', symbol: 'Be', atomicNumber: 4, atomicMass: 9.012 },
{ name: 'Boron', symbol: 'B', atomicNumber: 5, atomicMass: 10.81 },
];
const ExampleComponent = () => {
const hotRef = useRef(null);
useEffect(() => {
const hot = hotRef.current?.hotInstance;
hot?.updateSettings({
cells(row, col) {
const cellProperties = {};
if (hot.getData()[row][col] === 'Helium') {
cellProperties.readOnly = true;
}
return cellProperties;
},
});
});
return (
<HotTable
// licenseKey="your-license-key" // get a key at https://handsontable.com/pricing/
ref={hotRef}
data={data}
colHeaders={['Name', 'Symbol', 'Atomic number', 'Atomic mass']}
height="auto"
autoWrapRow={true}
autoWrapCol={true}
/>
);
};
export default ExampleComponent;
TypeScript
import { useRef, useEffect } from 'react';
import Handsontable from 'handsontable/base';
import { HotTable, HotTableRef } from '@handsontable/react-wrapper';
import { registerAllModules } from 'handsontable/registry';
// register Handsontable's modules
registerAllModules();
const data = [
{ name: 'Hydrogen', symbol: 'H', atomicNumber: 1, atomicMass: 1.008 },
{ name: 'Helium', symbol: 'He', atomicNumber: 2, atomicMass: 4.003 },
{ name: 'Lithium', symbol: 'Li', atomicNumber: 3, atomicMass: 6.94 },
{ name: 'Beryllium', symbol: 'Be', atomicNumber: 4, atomicMass: 9.012 },
{ name: 'Boron', symbol: 'B', atomicNumber: 5, atomicMass: 10.81 },
];
const ExampleComponent = () => {
const hotRef = useRef<HotTableRef>(null);
useEffect(() => {
const hot = hotRef.current?.hotInstance;
hot?.updateSettings({
cells(row, col) {
const cellProperties: Handsontable.CellMeta = {};
if (hot.getData()[row][col] === 'Helium') {
cellProperties.readOnly = true;
}
return cellProperties;
},
});
});
return (
<HotTable
// licenseKey="your-license-key" // get a key at https://handsontable.com/pricing/
ref={hotRef}
data={data}
colHeaders={['Name', 'Symbol', 'Atomic number', 'Atomic mass']}
height="auto"
autoWrapRow={true}
autoWrapCol={true}
/>
);
};
export default ExampleComponent;

Non-editable cells behave like any other cells apart from preventing you from manually changing their values.

Make a column non-editable

To make a column non-editable, declare it in the columns configuration option. The column’s basic behavior does not change — you can still use keyboard navigation, Ctrl/Cmd+C, Ctrl/Cmd+V, and drag-to-fill. The example below also defines a custom renderer that dims the non-editable column, giving the user a visual cue that its cells are non-editable.

JavaScript
import { HotTable } from '@handsontable/react-wrapper';
import { registerAllModules } from 'handsontable/registry';
import { textRenderer } from 'handsontable/renderers/textRenderer';
// register Handsontable's modules
registerAllModules();
const dimmedTextRenderer = (instance, td, ...rest) => {
textRenderer(instance, td, ...rest);
td.style.opacity = '0.6';
};
const data = [
{ name: 'Hydrogen', symbol: 'H', atomicNumber: 1, atomicMass: 1.008 },
{ name: 'Helium', symbol: 'He', atomicNumber: 2, atomicMass: 4.003 },
{ name: 'Lithium', symbol: 'Li', atomicNumber: 3, atomicMass: 6.94 },
{ name: 'Beryllium', symbol: 'Be', atomicNumber: 4, atomicMass: 9.012 },
{ name: 'Boron', symbol: 'B', atomicNumber: 5, atomicMass: 10.81 },
];
const ExampleComponent = () => {
return (
<HotTable
// licenseKey="your-license-key" // get a key at https://handsontable.com/pricing/
data={data}
height="auto"
colHeaders={['Name', 'Symbol', 'Atomic number', 'Atomic mass']}
autoWrapRow={true}
autoWrapCol={true}
columns={[
{
data: 'name',
editor: false,
renderer: dimmedTextRenderer,
},
{
data: 'symbol',
editor: 'text',
},
{
data: 'atomicNumber',
editor: 'numeric',
},
{
data: 'atomicMass',
editor: 'numeric',
},
]}
/>
);
};
export default ExampleComponent;
TypeScript
import { HotTable } from '@handsontable/react-wrapper';
import { registerAllModules } from 'handsontable/registry';
import { BaseRenderer } from 'handsontable/renderers';
import { textRenderer } from 'handsontable/renderers/textRenderer';
// register Handsontable's modules
registerAllModules();
const dimmedTextRenderer: BaseRenderer = (instance, td, ...rest) => {
textRenderer(instance, td, ...rest);
td.style.opacity = '0.6';
};
const data = [
{ name: 'Hydrogen', symbol: 'H', atomicNumber: 1, atomicMass: 1.008 },
{ name: 'Helium', symbol: 'He', atomicNumber: 2, atomicMass: 4.003 },
{ name: 'Lithium', symbol: 'Li', atomicNumber: 3, atomicMass: 6.94 },
{ name: 'Beryllium', symbol: 'Be', atomicNumber: 4, atomicMass: 9.012 },
{ name: 'Boron', symbol: 'B', atomicNumber: 5, atomicMass: 10.81 },
];
const ExampleComponent = () => {
return (
<HotTable
// licenseKey="your-license-key" // get a key at https://handsontable.com/pricing/
data={data}
height="auto"
colHeaders={['Name', 'Symbol', 'Atomic number', 'Atomic mass']}
autoWrapRow={true}
autoWrapCol={true}
columns={[
{
data: 'name',
editor: false,
renderer: dimmedTextRenderer,
},
{
data: 'symbol',
editor: 'text',
},
{
data: 'atomicNumber',
editor: 'numeric',
},
{
data: 'atomicMass',
editor: 'numeric',
},
]}
/>
);
};
export default ExampleComponent;

Make specific cells non-editable

To make specific cells non-editable, set editor: false in the cell configuration. The following example shows a table with non-editable cells containing the word “Helium”.

JavaScript
import { useRef, useEffect } from 'react';
import { HotTable } from '@handsontable/react-wrapper';
import { registerAllModules } from 'handsontable/registry';
// register Handsontable's modules
registerAllModules();
const data = [
{ name: 'Hydrogen', symbol: 'H', atomicNumber: 1, atomicMass: 1.008 },
{ name: 'Helium', symbol: 'He', atomicNumber: 2, atomicMass: 4.003 },
{ name: 'Lithium', symbol: 'Li', atomicNumber: 3, atomicMass: 6.94 },
{ name: 'Beryllium', symbol: 'Be', atomicNumber: 4, atomicMass: 9.012 },
{ name: 'Boron', symbol: 'B', atomicNumber: 5, atomicMass: 10.81 },
];
const ExampleComponent = () => {
const hotRef = useRef(null);
useEffect(() => {
const hot = hotRef.current?.hotInstance;
hot?.updateSettings({
cells(row, _col, prop) {
const cellProperties = {};
if (hot.getDataAtRowProp(row, prop) === 'Helium') {
cellProperties.editor = false;
} else {
cellProperties.editor = 'text';
}
return cellProperties;
},
});
});
return (
<HotTable
// licenseKey="your-license-key" // get a key at https://handsontable.com/pricing/
ref={hotRef}
data={data}
colHeaders={['Name', 'Symbol', 'Atomic number', 'Atomic mass']}
height="auto"
autoWrapRow={true}
autoWrapCol={true}
/>
);
};
export default ExampleComponent;
TypeScript
import { useRef, useEffect } from 'react';
import Handsontable from 'handsontable/base';
import { HotTable, HotTableRef } from '@handsontable/react-wrapper';
import { registerAllModules } from 'handsontable/registry';
// register Handsontable's modules
registerAllModules();
const data = [
{ name: 'Hydrogen', symbol: 'H', atomicNumber: 1, atomicMass: 1.008 },
{ name: 'Helium', symbol: 'He', atomicNumber: 2, atomicMass: 4.003 },
{ name: 'Lithium', symbol: 'Li', atomicNumber: 3, atomicMass: 6.94 },
{ name: 'Beryllium', symbol: 'Be', atomicNumber: 4, atomicMass: 9.012 },
{ name: 'Boron', symbol: 'B', atomicNumber: 5, atomicMass: 10.81 },
];
const ExampleComponent = () => {
const hotRef = useRef<HotTableRef>(null);
useEffect(() => {
const hot = hotRef.current?.hotInstance;
hot?.updateSettings({
cells(row, _col, prop) {
const cellProperties: Handsontable.CellMeta = {};
if (hot.getDataAtRowProp(row, prop as string) === 'Helium') {
cellProperties.editor = false;
} else {
cellProperties.editor = 'text';
}
return cellProperties;
},
});
});
return (
<HotTable
// licenseKey="your-license-key" // get a key at https://handsontable.com/pricing/
ref={hotRef}
data={data}
colHeaders={['Name', 'Symbol', 'Atomic number', 'Atomic mass']}
height="auto"
autoWrapRow={true}
autoWrapCol={true}
/>
);
};
export default ExampleComponent;

Read-only cells that look editable

By default, read-only cells carry the htDimmed CSS class, which greys them out. To keep a grid read-only while it still looks like a normal table, set readOnlyStyling to false:

readOnly: true,
readOnlyStyling: false,

Only the appearance changes. The cells still reject edits, pasting, and drag-to-fill, and screen readers still announce them as read-only.

Like readOnly itself, you can set readOnlyStyling for the whole grid, a column, or a single cell.

To change how read-only cells look, rather than to stop styling them, set readOnlyCellClassName to a class name of your own and style that class.

Non-editable cells and cell types

A cell type sets the editor, renderer, and validator options at once. A type set on a column does not re-enable editing that you disabled higher up, so this grid is non-editable throughout, and the second column still renders and validates as numeric:

editor: false,
columns: [
{ type: 'text' },
{ type: 'numeric' }
]

To let one column opt back in, give it an editor of its own, at the same configuration level as its type:

editor: false,
columns: [
{ type: 'text' },
// editable, despite the grid-level `editor: false`
{ type: 'numeric', editor: 'numeric' }
]

To keep the editor that the column’s type provides, without naming it, set editor: true, for example { type: 'numeric', editor: true }.

A custom cell type that declares editor: false supplies a default, not a setting of yours. If you set such a type on the whole grid, a column with a type of its own still gets that type’s editor.

If you switch editing off at runtime, pass columns in the same updateSettings() call. A column’s type writes its editor onto that column when the column is built, so editor: false passed without columns doesn’t reach a typed column:

// the numeric column stays editable
hot.updateSettings({ editor: false });
// the numeric column becomes non-editable too
hot.updateSettings({ editor: false, columns: [{ type: 'text' }, { type: 'numeric' }] });

A checkbox has no separate editing gesture — clicking the box is the edit — so a checkbox cell with no editor is rendered as a disabled checkbox. Neither a click nor the Space key toggles it. You can still select the cell.

Toggle read-only from the menus

The Read only item of the context menu and the column menu toggles the readOnly state of the selected cells.

The cells function runs again on top of every stored cell value, so a readOnly value that it sets, by returning it or by assigning it to this, always takes precedence over the menu. When the selection also holds other cells, the Read only item skips the ones that cells controls. It changes the rest, and its check mark reflects only them.

If cells sets readOnly on every selected cell, the item behaves as it always did: it stays in the menu, shows the cell state, and can’t change anything. This is the case when cells returns a readOnly value for every cell, for example { readOnly: false } as a default.

Undo and redo of a menu toggle change only the cells that the toggle changed. A cell that the Read only item skips keeps its stored value.

Block the entire grid

The readOnly and editor options control editing, but users can still navigate and select cells. To block all interaction with the grid temporarily — for example, during a loading state or a blocking workflow step — use the Dialog plugin. An open dialog overlays the grid and moves keyboard input into its own focus scope, so users can’t reach the cells until the dialog closes. The grid regains focus automatically.

Accessibility

When ariaTags is enabled (the default), Handsontable DataGrid adds aria-readonly="true" to the DOM element of every read-only cell, so screen readers announce that the cell can’t be edited. Non-editable cells (editor: false) don’t get this attribute, because Handsontable doesn’t treat them as read-only in the data model — only their editor is disabled.

For more accessibility features and testing guidance, see Accessibility.

Result

Read-only cells display with the htDimmed CSS class — unless you set readOnlyStyling to false — and block paste and drag-to-fill operations. Non-editable cells block manual editing but allow copy-paste and drag-to-fill.

Configuration options