align-items / align-self

Controls cross-axis alignment of columns. align-self overrides align-items for a specific column.

align-items (container):
align-self (col 2 "Department"):

Grid API — Canvas (WASM/Taffy)

Code

import { Grid, columnHelper } from "@ohah/react-wasm-table";

const helper = columnHelper<Person>();
const columns = [
  helper.accessor("name", { size: 180 }),
  helper.accessor("dept", { size: 120, alignSelf: "flex-end" }),
  helper.accessor("salary", { size: 100 }),
];

<Grid alignItems="center" rowHeight={60} columns={columns} data={data} height={520} />;

Table API Code

import {
  Table,
  useReactTable,
  flexRender,
  getCoreRowModel,
  Thead,
  Tbody,
  Tr,
  Th,
  Td,
} from "@ohah/react-wasm-table";

const table = useReactTable({ data, columns, getCoreRowModel: getCoreRowModel() });

<Table table={table} width={800} height={520} alignItems="center" rowHeight={60}>
  <Thead>
    {table.getHeaderGroups().map((hg) => (
      <Tr key={hg.id}>
        {hg.headers.map((h) => (
          <Th key={h.id} colSpan={h.colSpan}>
            {h.isPlaceholder ? null : flexRender(h.column.columnDef.header, h.getContext())}
          </Th>
        ))}
      </Tr>
    ))}
  </Thead>
  <Tbody>
    {table.getRowModel().rows.map((row) => (
      <Tr key={row.id}>
        {row.getVisibleCells().map((cell) => (
          <Td key={cell.id}>{flexRender(cell.column.columnDef.cell, cell.getContext())}</Td>
        ))}
      </Tr>
    ))}
  </Tbody>
</Table>;