An open source design system that's fully customizable and agent ready
TypeScript
// Copyright (c) Meta Platforms, Inc. and affiliates.
'use client';
import {Table, proportional, pixel} from '@astryxdesign/core/Table';
import type {TableColumn} from '@astryxdesign/core/Table';
import {Badge} from '@astryxdesign/core/Badge';
import {Link} from '@astryxdesign/core/Link';
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: '[email protected]',
role: 'Engineer',
age: 30,
},
{
id: '2',
name: 'Bob Smith',
email: '[email protected]',
role: 'Designer',
age: 25,
},
{
id: '3',
name: 'Charlie Brown',
email: '[email protected]',
role: 'PM',
age: 35,
},
{
id: '4',
name: 'Diana Prince',
email: '[email protected]',
role: 'Engineer',
age: 28,
},
{
id: '5',
name: 'Eve Davis',
email: '[email protected]',
role: 'Designer',
age: 32,
},
];
const roleVariant: Record<string, 'blue' | 'purple' | 'green'> = {
Engineer: 'blue',
Designer: 'purple',
PM: 'green',
};
const columns: TableColumn<User>[] = [
{key: 'name', header: 'Name'},
{
key: 'email',
header: 'Email',
width: proportional(2),
renderCell: item => <Link href={`mailto:${item.email}`}>{item.email}</Link>,
},
{
key: 'role',
header: 'Role',
renderCell: item => (
<Badge label={item.role} variant={roleVariant[item.role] ?? 'neutral'} />
),
},
{key: 'age', header: 'Age', width: pixel(80)},
];
export default function TableRichCellTable() {
return <Table data={users} columns={columns} idKey="id" hasHover />;
}