Table

Presents related data in semantic rows and columns.

On this page

This docs is LLM-friendly and available as clean Markdown.

Supported browser agents can also use WebMCP to search, read, and open these docs. Learn more

Usage

import {
  GlTable,
  GlTableBody,
  GlTableCaption,
  GlTableCell,
  GlTableFooter,
  GlTableHead,
  GlTableHeader,
  GlTableRow,
} from "gitlab-ui-react/table";
<GlTable>
  <GlTableCaption>Project members</GlTableCaption>
  <GlTableHeader>
    <GlTableRow>
      <GlTableHead>Name</GlTableHead>
    </GlTableRow>
  </GlTableHeader>
  <GlTableBody>
    <GlTableRow>
      <GlTableCell>Norcleeh</GlTableCell>
    </GlTableRow>
  </GlTableBody>
  <GlTableFooter>
    <GlTableRow>
      <GlTableCell>1 member</GlTableCell>
    </GlTableRow>
  </GlTableFooter>
</GlTable>

Default

Use semantic table parts to preserve the relationship between headers and cells. Data processing such as sorting, filtering, and pagination remains the responsibility of the parent.

Example data table
Example entities
NameTypeContext
Norcleeh
User name
OPanel
@NriotHrreion
User ID
Profile
Nocpiun
Organization
OPanel

Striped

Use striped to add alternating backgrounds when they help users distinguish adjacent rows.

Striped table
Project members
NameRole
NorcleehMaintainer
@NriotHrreionDeveloper

Bordered

Use bordered when every cell needs a visible boundary.

Bordered table
Project members
NameRole
NorcleehMaintainer
@NriotHrreionDeveloper

Compact

Use small to reduce cell padding in dense, text-focused data sets.

Compact table
Project members
NameRole
NorcleehMaintainer
@NriotHrreionDeveloper

Responsive tables

Set stacked to true or a breakpoint when rows should become labeled blocks at smaller widths. Supply stackedHeading on each cell so its column label remains visible in stacked mode.

Stacked table
Project members
NameRoleOrganization
Norcleeh
Maintainer
Nocpiun
NriotHrreion
Developer
Nocpiun

Set stickyHeader when users need column headings to remain visible while a long table scrolls. A CSS length also limits the scrolling region’s height.

Table with sticky header
Pipeline history
PipelineStatus
Pipeline 1Passed
Pipeline 2Running
Pipeline 3Passed
Pipeline 4Running
Pipeline 5Passed
Pipeline 6Running
Pipeline 7Passed
Pipeline 8Running
Pipeline 9Passed
Pipeline 10Running

Accessibility

  • Add GlTableCaption to describe the table. A visually hidden caption is preferable to omitting one.
  • Use GlTableHead with scope="col" for column headers and scope="row" for row headers.
  • Keep table structure for genuinely tabular data; use a list for unrelated items.
  • When sorting is implemented by the parent, expose the sort state with aria-sort and use a keyboard-accessible control in the header.

API

GlTable

Prop Description Default
bordered Adds borders around every cell. false
borderless Removes table borders and takes visual precedence over bordered. false
captionTop Places the caption above the table. false
fixed Uses a fixed table layout. false
hover Highlights body rows on hover. false
noBorderCollapse Separates cell borders instead of collapsing them. false
outlined Adds an outer border. false
small Uses compact cell padding. false
stacked Stacks rows at every width or below sm, md, lg, or xl. false
stickyHeader Makes the header sticky; a string also sets the wrapper’s maximum height. false
striped Adds alternating row backgrounds. false

GlTableCaption

Accepts children and supported caption attributes.

GlTableHeader

Accepts children and supported thead attributes.

GlTableBody

Accepts children and supported tbody attributes.

GlTableFooter

Accepts children and supported tfoot attributes.

GlTableRow

Accepts children and supported tr attributes.

GlTableHead

Prop Description Default
scope Defines whether GlTableHead labels a row or column. "col"
stackedHeading Supplies the visible header-cell label in stacked mode.

GlTableCell

Prop Description Default
stackedHeading Supplies the visible data-cell label in stacked mode.