The Table
component is versatile and supports different styles and configurations. Below are examples showcasing different table types.
Name | Age | Occupation |
---|---|---|
John Doe | 28 | Software Engineer |
Jane Smith | 34 | Product Manager |
Sam Brown | 22 | Designer |
import Table from '../../components/Table';
const BasicTable: React.FC = () => {
const columns = ['Name', 'Age', 'Occupation'];
const data = [
{ Name: 'John Doe', Age: 28, Occupation: 'Software Engineer' },
{ Name: 'Jane Smith', Age: 34, Occupation: 'Product Manager' },
{ Name: 'Sam Brown', Age: 22, Occupation: 'Designer' },
];
return <Table columns={columns} data={data} variant="basic" />;
};
export default BasicTable;
Name | Age | Occupation |
---|---|---|
John Doe | 28 | Software Engineer |
Jane Smith | 34 | Product Manager |
Sam Brown | 22 | Designer |
import Table from '../../components/Table';
const StripedTable: React.FC = () => {
const columns = ['Name', 'Age', 'Occupation'];
const data = [
{ Name: 'John Doe', Age: 28, Occupation: 'Software Engineer' },
{ Name: 'Jane Smith', Age: 34, Occupation: 'Product Manager' },
{ Name: 'Sam Brown', Age: 22, Occupation: 'Designer' },
];
return <Table columns={columns} data={data} variant="striped" />;
};
export default StripedTable;
Name | Age | Occupation |
---|---|---|
John Doe | 28 | Software Engineer |
Jane Smith | 34 | Product Manager |
Sam Brown | 22 | Designer |
Expanded Content for Row 3 |
import Table from '../../components/Table';
const ExpandableTable: React.FC = () => {
const columns = ['Name', 'Age', 'Occupation'];
const data = [
{ Name: 'John Doe', Age: 28, Occupation: 'Software Engineer' },
{ Name: 'Jane Smith', Age: 34, Occupation: 'Product Manager' },
{ Name: 'Sam Brown', Age: 22, Occupation: 'Designer' },
];
return (
<Table
columns={columns}
data={data}
variant="expandable"
expandable
onRowExpand={(rowIndex) => console.log('Expanded row:', rowIndex)}
/>
);
};
export default ExpandableTable;