Canvas: Flex
Flex is a Taffy-compatible flex container. Use multiple children (e.g. Badge + Text) to see flexDirection, gap, alignItems, justifyContent in action.
Toggle Flex props
flexDirection:
gap:
alignItems:
justifyContent:
Pass via:
Canvas preview
Grid API
#Code
import { Grid, createColumnHelper, Flex, Badge, Text } from "@ohah/react-wasm-table";
const helper = createColumnHelper<{ dept: string; salary: number }>();
const columns = [
helper.accessor("dept", {
header: "Flex Layout",
size: 420,
cell: (info) => (
<Flex flexDirection="row" gap={8} alignItems="center" justifyContent="start">
<Badge value={info.getValue()} backgroundColor="#e3f2fd" color="#1565c0" />
<Text value={String(info.row.original.salary)} fontSize={11} color="#888" />
</Flex>
),
}),
];
<Grid data={data} columns={columns} width={440} height={480} rowHeight={120} />;#Table API Code
import {
Table,
useReactTable,
flexRender,
getCoreRowModel,
Thead,
Tbody,
Tr,
Th,
Td,
createColumnHelper,
Flex,
Badge,
Text,
} from "@ohah/react-wasm-table";
const helper = createColumnHelper<{ dept: string; salary: number }>();
const columns = [
helper.accessor("dept", {
header: "Flex Layout",
size: 420,
cell: (info) => (
<Flex flexDirection="row" gap={8} alignItems="center" justifyContent="start">
<Badge value={info.getValue()} backgroundColor="#e3f2fd" color="#1565c0" />
<Text value={String(info.row.original.salary)} fontSize={11} color="#888" />
</Flex>
),
}),
];
const table = useReactTable({ data, columns, getCoreRowModel: getCoreRowModel() });
<Table table={table} width={440} height={480} rowHeight={120}>
<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>;