Tabla (Table)
El componente Table (Tabla) es un contenedor de datos flexible que te permite mostrar datos tabulares con varias opciones de personalización. La tabla está compuesta por varios subcomponentes que incluyen TableBody, TableHeader, TableRow y TableCell, los cuales ofrecen estilos distintos para diferentes secciones de la tabla.
Para usar el componente Table, generalmente usarás una combinación de los componentes Table, TableBody, TableHeader, TableRow y TableCell.
Tabla básica
Sección titulada «Tabla básica»Una tabla básica que muestra la estructura predeterminada.
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> );}Tabla con estilos personalizados
Sección titulada «Tabla con estilos personalizados»Aplica cualquier estilo o atributos básicos a los componentes de la tabla.
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> );}