Skip to content
IndexRequest a UIAboutContact

Sticky Table Header & Column

A wide table scrolls both ways while its header row and first column stay pinned, with edge shadows.

Open alone ↗

AI prompt

PROMPT: PASTE INTO YOUR AI CODING TOOL
Clean UI mockup of a wide data table in a rounded scroll area, the first column of product names and the top header row both pinned with a soft shadow along their inner edges, pale grey header background, thin row dividers, numeric columns right aligned, the table partially scrolled so that columns in the middle are visible while the labels stay in place, light theme, flat modern style. Negative: heavy shadows, gradients, clutter, text errors, device frames. Reduced motion: static design.

About this pattern

Definition

Large tables are hard to read when you lose the column titles or row labels as you scroll. position: sticky pins the header row to the top and the first column to the left, like frozen panes in a spreadsheet, so each cell stays linked to its labels.

Purpose & UX principles

  • Give th in the header top: 0 and the first-column cells left: 0, with an opaque background and a higher z-index at the corner.
  • Put the table in a scroll container with a fixed height.
  • Add a shadow or border to the pinned edges only while content scrolls beneath them.
  • Keep the pinned column narrow so there is room for data.

Interaction states

  • A table with 8 columns and 12 rows; scroll or use the keyboard.

Motion specification

  • Shadows fade in over 150ms when you scroll.
  • Reduced motion: no fade.

Responsive behaviour

  • Make the scroll container focusable so keyboard users can scroll it.
  • On small screens consider turning rows into cards instead.

Code

HTML
<div class="bx"><div class="sc" id="sc" tabindex="0" aria-label="Sales table, scrollable"><table id="tb"></table></div><p class="out" id="out"></p></div>

Related patterns

Sticky Header that Shrinks

↗
Sticky Header that ShrinksLayout & Scrolling

Split Pane Resizer

↗
Split Pane ResizerLayout & Scrolling

Sortable Ranking Bars

↗
Sortable Ranking BarsData Visualization