Tabela (Table)
O componente Table é um contêiner de dados flexível que permite exibir dados tabulares com várias opções de personalização. A tabela é composta por vários subcomponentes incluindo TableBody, TableHeader, TableRow e TableCell que oferecem estilo distinto para diferentes seções da tabela.
Para usar o componente Table, você geralmente usará uma combinação de Table, TableBody, TableHeader, TableRow e TableCell.
Table básica
Seção intitulada “Table básica”Uma tabela básica mostrando a estrutura padrão.
import React from "react";import { Table, TableBody, TableHeader, TableRow, TableCell } from "@firecms/ui";
export default function TableBasicDemo() { return ( <Table> <TableHeader> <TableCell header scope="col">Name</TableCell> <TableCell header scope="col">Age</TableCell> <TableCell header scope="col">City</TableCell> </TableHeader> <TableBody> <TableRow> <TableCell>John Doe</TableCell> <TableCell>30</TableCell> <TableCell>New York</TableCell> </TableRow> <TableRow> <TableCell>Jane Smith</TableCell> <TableCell>25</TableCell> <TableCell>San Francisco</TableCell> </TableRow> </TableBody> </Table> );}Table with Custom Styling
Seção intitulada “Table with Custom Styling”Aplique qualquer estilo ou atributos base aos componentes da tabela.
import React from "react";import { Table, TableBody, TableHeader, TableRow, TableCell } from "@firecms/ui";
export default function TableCustomHeadingDemo() { return ( <Table className="bg-surface-50 dark:bg-surface-900"> <TableHeader className="bg-surface-50 dark:bg-surface-800"> <TableCell header scope="col" className="custom-header-cell">Product</TableCell> <TableCell header scope="col" className="custom-header-cell">Price</TableCell> <TableCell header scope="col" className="custom-header-cell">Stock</TableCell> </TableHeader> <TableBody className="bg-surface-100 dark:bg-surface-900"> <TableRow className="hover:bg-surface-200 hover:dark:bg-surface-800" onClick={() => console.log("Clicked")}> <TableCell>Apple</TableCell> <TableCell className="bg-surface-200 dark:bg-surface-700">$1.00</TableCell> <TableCell>In Stock</TableCell> </TableRow> <TableRow className="hover:bg-surface-200 hover:dark:bg-surface-800" onClick={() => console.log("Clicked")}> <TableCell>Banana</TableCell> <TableCell className="bg-surface-200 dark:bg-surface-700">$0.50</TableCell> <TableCell>Out of Stock</TableCell> </TableRow> </TableBody> </Table> );}