---
title: "Cell Text Selection"
framework: react
version: "36.1.0"
---

# Cell Text Selection

The grid can be configured to allow simple text selection.

![Cell Text Selection](https://www.ag-grid.com/_astro/cellTextSelection.Cah3lrQ8.png)

## Enabling Cell Text Selection

To enable text selection as if the grid were a regular table, set the grid option `enableCellTextSelection = true`. For the selection to work correctly, the order of the rows within the DOM must match what is displayed by setting the grid option `ensureDomOrder = true`.

#### Cell Text Selection

```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,
  ModuleRegistry,
  enableDevValidations,
} from "ag-grid-community";
import { IOlympicData } from "./interfaces";
import { useFetchJson } from "./useFetchJson";

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

const modules = [ClientSideRowModelModule];

const GridExample = () => {
  const containerStyle = useMemo(() => ({ width: "100%", height: "100%" }), []);
  const gridStyle = useMemo(() => ({ height: "100%", width: "100%" }), []);

  const [columnDefs, setColumnDefs] = useState<ColDef[]>([
    { field: "athlete" },
    { field: "sport" },
    { field: "age" },
  ]);

  const { data, loading } = useFetchJson<IOlympicData>(
    "https://www.ag-grid.com/example-assets/olympic-winners.json",
  );

  return (
    <AgGridProvider modules={modules}>
      <div style={containerStyle}>
        <div style={gridStyle}>
          <AgGridReact<IOlympicData>
            rowData={data}
            loading={loading}
            columnDefs={columnDefs}
            enableCellTextSelection={true}
            ensureDomOrder={true}
          />
        </div>
      </div>
    </AgGridProvider>
  );
};

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

[Live example: Cell Text Selection](https://www.ag-grid.com/examples/cell-text-selection/cell-text-selection/reactFunctionalTs/)

When `enableCellTextSelection` is set to `true`, the default [Clipboard](https://www.ag-grid.com/react-data-grid/clipboard/) behaviour is disabled, and only the selected text is copied.
