Skip to content

Text cell type

Use the text cell type, the default cell type in Handsontable, to display and edit plain text values.

Overview

The text cell type is the default cell type in Handsontable. It renders a cell’s value as plain text and lets you edit it with a standard text input. It has no built-in validator.

Because text is the default, you don’t need to set type: 'text' for it to apply. Set it explicitly when you want to override a different type inherited from a higher configuration level, or when you want the configuration to state the type directly, for example to guard alphanumeric codes or values with leading zeros against being reformatted by another type.

JavaScript
import { HotTable } from '@handsontable/react-wrapper';
import { registerAllModules } from 'handsontable/registry';
// register Handsontable's modules
registerAllModules();
const ExampleComponent = () => {
return (<HotTable data={[
{ sku: '004821', category: '032', quantity: 142, unitPrice: 18.5 },
{ sku: '000093', category: '032', quantity: 0, unitPrice: 42.0 },
{ sku: '017640', category: '015', quantity: 67, unitPrice: 9.99 },
{ sku: '002210', category: '015', quantity: 310, unitPrice: 4.25 },
{ sku: '008875', category: '048', quantity: 24, unitPrice: 129.0 },
]} colHeaders={['SKU', 'Category code', 'Quantity', 'Unit price ($)']} height="auto" autoWrapRow={true} autoWrapCol={true} licenseKey="non-commercial-and-evaluation" columns={[
{ data: 'sku', type: 'text' },
{ data: 'category', type: 'text' },
{ data: 'quantity', type: 'numeric' },
{ data: 'unitPrice', type: 'numeric' },
]}/>);
};
export default ExampleComponent;
TypeScript
import { HotTable } from '@handsontable/react-wrapper';
import { registerAllModules } from 'handsontable/registry';
// register Handsontable's modules
registerAllModules();
const ExampleComponent = () => {
return (
<HotTable
data={[
{ sku: '004821', category: '032', quantity: 142, unitPrice: 18.5 },
{ sku: '000093', category: '032', quantity: 0, unitPrice: 42.0 },
{ sku: '017640', category: '015', quantity: 67, unitPrice: 9.99 },
{ sku: '002210', category: '015', quantity: 310, unitPrice: 4.25 },
{ sku: '008875', category: '048', quantity: 24, unitPrice: 129.0 },
]}
colHeaders={['SKU', 'Category code', 'Quantity', 'Unit price ($)']}
height="auto"
autoWrapRow={true}
autoWrapCol={true}
licenseKey="non-commercial-and-evaluation"
columns={[
{ data: 'sku', type: 'text' },
{ data: 'category', type: 'text' },
{ data: 'quantity', type: 'numeric' },
{ data: 'unitPrice', type: 'numeric' },
]}
/>
);
};
export default ExampleComponent;

In the example above, the sku and category columns use type: 'text' explicitly, even though it’s the default. This makes the configuration self-documenting: values such as '004821' are alphanumeric codes with leading zeros, not numbers, and the explicit type states that intent even if a later change sets a different type at the grid or column level.

Adding a validator

The text cell type ships without a built-in validator. To validate text values, combine type: 'text' with your own validator function, and set allowInvalid to false to reject invalid entries.

With allowInvalid: false, the cell editor doesn’t close on an invalid value. It stays open until you either enter a value that passes validation or press Esc to cancel the edit and restore the previous value. See invalid cell commit semantics for the full behavior, including how it differs from allowInvalid: true.

JavaScript
import { HotTable } from '@handsontable/react-wrapper';
import { registerAllModules } from 'handsontable/registry';
// register Handsontable's modules
registerAllModules();
const skuValidator = (value, callback) => {
callback(/^\d{6}$/.test(value));
};
const ExampleComponent = () => {
return (<HotTable data={[
{ sku: '004821', supplier: 'Harbor Goods', quantity: 142 },
{ sku: '000093', supplier: 'Alpine Supply Co.', quantity: 0 },
{ sku: '017640', supplier: 'Harbor Goods', quantity: 67 },
{ sku: '002210', supplier: 'Crestline Wholesale', quantity: 310 },
{ sku: '008875', supplier: 'Alpine Supply Co.', quantity: 24 },
]} colHeaders={['SKU', 'Supplier', 'Quantity']} height="auto" autoWrapRow={true} autoWrapCol={true} licenseKey="non-commercial-and-evaluation" columns={[
{ data: 'sku', type: 'text', validator: skuValidator, allowInvalid: false },
{ data: 'supplier', type: 'text' },
{ data: 'quantity', type: 'numeric' },
]}/>);
};
export default ExampleComponent;
TypeScript
import { HotTable } from '@handsontable/react-wrapper';
import { registerAllModules } from 'handsontable/registry';
// register Handsontable's modules
registerAllModules();
const skuValidator = (value: string, callback: (isValid: boolean) => void) => {
callback(/^\d{6}$/.test(value));
};
const ExampleComponent = () => {
return (
<HotTable
data={[
{ sku: '004821', supplier: 'Harbor Goods', quantity: 142 },
{ sku: '000093', supplier: 'Alpine Supply Co.', quantity: 0 },
{ sku: '017640', supplier: 'Harbor Goods', quantity: 67 },
{ sku: '002210', supplier: 'Crestline Wholesale', quantity: 310 },
{ sku: '008875', supplier: 'Alpine Supply Co.', quantity: 24 },
]}
colHeaders={['SKU', 'Supplier', 'Quantity']}
height="auto"
autoWrapRow={true}
autoWrapCol={true}
licenseKey="non-commercial-and-evaluation"
columns={[
{ data: 'sku', type: 'text', validator: skuValidator, allowInvalid: false },
{ data: 'supplier', type: 'text' },
{ data: 'quantity', type: 'numeric' },
]}
/>
);
};
export default ExampleComponent;

Result

After configuring the text cell type, cells display and edit their value as plain text, with no formatting or masking applied. Combine it with a custom validator to restrict which values a text cell accepts.

Keyboard shortcuts

The text cell editor uses the standard edition keyboard shortcuts. It has no type-specific key bindings.

Related guides

Configuration options

Core methods

Hooks