📄 tanstack/table/latest/docs/guide/header-groups

File: header-groups.md | Updated: 11/15/2025

Source: https://tanstack.com/table/latest/docs/guide/header-groups



TanStack

Table v8v8

Search...

+ K

Auto

Log In

TanStack StartRC

Docs Examples GitHub Contributors

TanStack Router

Docs Examples GitHub Contributors

TanStack Query

Docs Examples GitHub Contributors

TanStack Table

Docs Examples Github Contributors

TanStack Formnew

Docs Examples Github Contributors

TanStack DBbeta

Docs Github Contributors

TanStack Virtual

Docs Examples Github Contributors

TanStack Paceralpha

Docs Examples Github Contributors

TanStack Storealpha

Docs Examples Github Contributors

TanStack Devtoolsalpha

Docs Github Contributors

More Libraries

Maintainers Partners Support Learn StatsBETA Discord Merch Blog GitHub Ethos Brand Guide

Documentation

Framework

React logo

React

Version

Latest

Search...

+ K

Menu

Getting Started

Core Guides

Feature Guides

Core APIs

Feature APIs

Enterprise

Examples

Framework

React logo

React

Version

Latest

Menu

Getting Started

Core Guides

Feature Guides

Core APIs

Feature APIs

Enterprise

Examples

On this page

Header Groups Guide

Copy Markdown

API
---

Header Group API

Header Groups Guide
-------------------

This quick guide will discuss the different ways you can retrieve and interact with header group objects in TanStack Table.

### What are Header Groups?

Header Groups are simply "rows" of headers. Don't let the name confuse you, it's just that simple. The large majority of tables will only have one row of headers (a single header group), but if you define your column structure with nested columns as with the Column Groups example , you can have multiple rows of headers (multiple header groups).

### Where to Get Header Groups From

There are multiple table instance APIs you can use to retrieve header groups from the table instance. table.getHeaderGroups is the most common API to use, but depending on the features that you are using, you may need to use other APIs, such as table.get[Left/Center/Right]HeaderGroups if you are using column pinning features.

### Header Group Objects

Header Group objects are similar to Row objects, though simpler since there is not as much going on in header rows as there are in the body rows.

By default, header groups only have three properties:

  • id: The unique identifier for the header group that is generated from its depth (index). This is useful as a key for React components.
  • depth: The depth of the header group, zero-indexed based. Think of this as the row index amongst all header rows.
  • headers: An array of Header cell objects that belong to this header group (row).

### Access Header Cells

To render the header cells in a header group, you just map over the headers array from the header group object.

jsx

<thead>
  {table.getHeaderGroups().map(headerGroup => {
    return (
      <tr key={headerGroup.id}>
        {headerGroup.headers.map(header => ( // map over the headerGroup headers array
          <th key={header.id} colSpan={header.colSpan}>
            {/* */}
          </th>
        ))}
      </tr>
    )
  })}
</thead>


<thead>
  {table.getHeaderGroups().map(headerGroup => {
    return (
      <tr key={headerGroup.id}>
        {headerGroup.headers.map(header => ( // map over the headerGroup headers array
          <th key={header.id} colSpan={header.colSpan}>
            {/* */}
          </th>
        ))}
      </tr>
    )
  })}
</thead>

Edit on GitHub

Cells

Headers

Partners Become a Partner

Code RabbitCode Rabbit CloudflareCloudflare AG GridAG Grid NetlifyNetlify NeonNeon WorkOSWorkOS ClerkClerk ConvexConvex ElectricElectric SentrySentry PrismaPrisma StrapiStrapi UnkeyUnkey

scarf analytics