Grid

A virtualized data grid for displaying large, spreadsheet-like datasets. Grid renders only the visible cells and supports cell selection, keyboard navigation, column resizing, context menus and copying. For page layout, use GridContainer or Container instead.

Example

of 5

Props

Prop
Type
Default value
Description
Prop
rowCount *
Type
number
Default value
required
Description
Total number of rows in the grid
Prop
columnCount *
Type
number
Default value
required
Description
Total number of columns in the grid
Prop
cell *
Type
CellProps
Default value
required
Description
Component that renders a cell. It receives rowIndex, columnIndex and type ("row-cell" or "header-cell").
Prop
rowStart
Type
number
Default value
undefined
Description
Number of the first row, used for row numbers when the data is paginated
Prop
rowHeight
Type
number
Default value
undefined
Description
Height of each row in pixels
Prop
rowAutoHeight
Type
boolean
Default value
undefined
Description
If true, rows grow to fit their content
Prop
headerHeight
Type
number
Default value
undefined
Description
Height of the header row in pixels
Prop
columnWidth
Type
(index: number) => number
Default value
undefined
Description
Returns the width in pixels of the column at the given index
Prop
onColumnResize
Type
(columnIndex: number, newWidth: number) => void
Default value
undefined
Description
Called when a column is resized
Prop
showHeader
Type
boolean
Default value
undefined
Description
Whether to show the header row
Prop
showRowNumber
Type
boolean
Default value
undefined
Description
Whether to show the row number column
Prop
showBorder
Type
boolean
Default value
undefined
Description
Whether to show a border around the grid
Prop
rounded
Type
RoundedType
Default value
undefined
Description
Corner radius of the grid
Prop
autoHeight
Type
boolean
Default value
undefined
Description
If true, the grid grows to the height of its rows instead of filling its parent
Prop
autoFocus
Type
boolean
Default value
undefined
Description
If true, the grid takes focus when it mounts
Prop
focus
Type
SelectionFocus
Default value
undefined
Description
The focused cell, as a row and column index
Prop
onFocusChange
Type
(rowIndex: number, columnIndex: number) => void
Default value
undefined
Description
Called when the focused cell changes
Prop
selection
Type
SelectedRegion
Default value
undefined
Description
The selected region, for controlled selection
Prop
onSelect
Type
(action: SelectionAction, selection: SelectedRegion, focus: SelectionFocus) => void
Default value
undefined
Description
Called when the selection changes
Prop
getMenuOptions
Type
(selection: SelectedRegion, focus: SelectionFocus) => GridContextMenuItemProps[]
Default value
undefined
Description
Returns the context menu items for the current selection
Prop
onCopy
Type
(selection: SelectedRegion, focus: SelectionFocus) => void | Promise<void>
Default value
undefined
Description
Replaces the default copy behaviour
Prop
onCopyCallback
Type
(copied: boolean) => void
Default value
undefined
Description
Called after a copy attempt with whether it succeeded
Prop
showToast
Type
boolean
Default value
undefined
Description
Whether to show a toast after copying

* denotes required field

Quick start

import { Grid } from '@clickhouse/click-ui'

function MyGrid() {
  return (
    <div style={{ height: 500, width: '100%' }}>
      <Grid
        rowStart={0}
        columnCount={5}
        rowCount={10}
        cell={Cell}
        headerHeight={32}
        focus={focus}
        onFocusChange={(row, column) => setFocus({ row, column })}
      />
    </div>
  )
}
  • GridContainer: For CSS Grid-based layouts with flexible column definitions.
  • Container: For flexbox-based layouts, an alternative to Grid.
  • Panel: Often used within grid cells for card layouts.

Common use cases

Responsive grid

Grid is commonly used for data tables and structured content. See the example above for a complete implementation.

import { Grid, Pagination } from '@clickhouse/click-ui'
import { useState } from 'react'

function ResponsiveGrid() {
  const [currentPage, setCurrentPage] = useState(0)
  const [focus, setFocus] = useState({ row: 0, column: 0 })
  
  return (
    <div style={{ height: 500, width: '100%' }}>
      <Grid
        rowStart={currentPage * 10}
        columnCount={5}
        rowCount={10}
        cell={Cell}
        headerHeight={32}
        focus={focus}
        onFocusChange={(row, column) => setFocus({ row, column })}
      />
      <Pagination
        currentPage={currentPage}
        onChange={setCurrentPage}
        totalPages={5}
      />
    </div>
  )
}

© 2026 ClickHouse, Inc. HQ in the Bay Area, CA and Amsterdam, NL.