EXEPERTAI LAB

Research alpha

Time Machine
EXEPERTAI LAB
GALLERY / COLLECTION
← Browse Astryx gallery
Table·component·@astryxdesign/core

Table Header

<thead> wrapper for children mode. Holds the header row, whose cells are TableHeaderCell. A row must sit inside a section: <table> cannot contain a <tr> directly, because the HTML parser inserts an implied <tbody> when it parses server-rendered markup and React does not when it renders on the client, so the two trees mismatch on hydration. The data-driven data={...} mode renders this element itself whenever columns are supplied; in children mode it is yours to supply.

Open in Playground @astryxdesign/core/Table

Showcases and examples

12 documented examples · Context from Table

Table

Data-driven table with proportional and pixel column widths and hover highlighting.

Preview loads on approachPreview loads on approach
Exact source · table-showcase
// Copyright (c) Meta Platforms, Inc. and affiliates.

'use client';

import {Table, proportional, pixel} from '@astryxdesign/core/Table';
import {Card} from '@astryxdesign/core/Card';
import type {TableColumn} from '@astryxdesign/core/Table';

interface User extends Record<string, unknown> {
  id: string;
  name: string;
  email: string;
  role: string;
  age: number;
}

const users: User[] = [
  {
    id: '1',
    name: 'Alice Johnson',
    email: 'alice@example.com',
    role: 'Engineer',
    age: 30,
  },
  {
    id: '2',
    name: 'Bob Smith',
    email: 'bob@example.com',
    role: 'Designer',
    age: 25,
  },
  {
    id: '3',
    name: 'Charlie Brown',
    email: 'charlie@example.com',
    role: 'PM',
    age: 35,
  },
];

const columns: TableColumn<User>[] = [
  {key: 'name', header: 'Name', width: proportional(1)},
  {key: 'email', header: 'Email', width: proportional(2)},
  {key: 'role', header: 'Role', width: proportional(1)},
  {key: 'age', header: 'Age', width: pixel(80)},
];

export default function TableShowcase() {
  return (
    <Card width={600}>
      <Table data={users} columns={columns} idKey="id" hasHover />
    </Card>
  );
}

Usage

<thead> wrapper for children mode. Holds the header row, whose cells are TableHeaderCell. A row must sit inside a section: <table> cannot contain a <tr> directly, because the HTML parser inserts an implied <tbody> when it parses server-rendered markup and React does not when it renders on the client, so the two trees mismatch on hydration. The data-driven data={...} mode renders this element itself whenever columns are supplied; in children mode it is yours to supply.

Typed props

PropType and behavior
childrenReactNode · required
The <thead> rows.
xstyleStyleXStyles
StyleX styles for layout customization. Must be a stylex.create() value: not an inline style object like style={{}}.

Theming

Targets

astryx-table-header