Table
El componente Table nos permite organizar los datos con una estructura tabular en una tabla.
import React from "react";
import { Table } from "@nimbus-ds/components";
const headers = ["Header 1", "Header 2", "Header 3", "Header 4"];
const rows = ["Cell 1", "Cell 2", "Cell 3", "Cell 4"];
const Example: React.FC = () => (
<Table>
<Table.Head>
{headers.map((header) => (
<Table.Cell key={header}>{header}</Table.Cell>
))}
</Table.Head>
<Table.Body>
{rows.map((row) => (
<Table.Row key={row}>
<Table.Cell>Cell 1</Table.Cell>
<Table.Cell>Cell 2</Table.Cell>
<Table.Cell>Cell 3</Table.Cell>
<Table.Cell>Cell 4</Table.Cell>
</Table.Row>
))}
</Table.Body>
</Table>
);
export default Example;El componente está formado por un header con estilos diferenciados, filas y columnas.
Utilizamos el Table para organizar la información en forma tabular en filas y columnas, utilizando las filas para ordenar las entradas que son similares en estructura pero diferentes en información verticalmente y diferentes tipos de datos horizontalmente.
Cada celda tiene un children que puede recibir texto u otros componentes Nimbus, lo que permite una variedad de configuraciones personalizadas para cada caso de uso.
- Organizar una lista de ventas
- Organizar una lista de productos
- Organizar datos de estructura similar
- Data list - Puede utilizarse cuando necesitamos una estructura de datos diferenciada o más compleja, por ejemplo en contextos móviles.
Instalá el componente via terminal.
npm install @nimbus-ds/tableLas propiedades adicionales se pasan al elemento <Table>. Consultá la documentación para ver la lista de atributos aceptados por el elemento <Table>.
Table
| Name | Type | Default | Description |
|---|---|---|---|
children* | React.ReactNode | The content of the table. | |
columnLayout | array | Column sizing definitions applied from left to right. Use `width` for fixed columns and `grow` to distribute the remaining space proportionally. | |
minWidth | string | Minimum width of the table. When the container is smaller, horizontal scrolling is enabled. Accepts any valid CSS width value (e.g., "600px", "50rem"). | |
maxWidth | string | Maximum width of the table. The table will not exceed this width. Accepts any valid CSS width value (e.g., "1200px", "80rem"). | |
stickyScrollbar | boolean | 'false' | Shows a sticky scrollbar at the bottom of the viewport when the table overflows horizontally. The scrollbar stays visible while scrolling vertically, making it easier to navigate wide tables. |
Table.Body
| Name | Type | Default | Description |
|---|---|---|---|
children* | React.ReactNode | The content of the table body. |
Table.Cell
| Name | Type | Default | Description |
|---|---|---|---|
children* | React.ReactNode | The content of the table cell. | |
as | 'td' | 'td' | Type of html tag to create for the table cell. |
column | number | Column index (0-based) to apply minWidth constraint from the Table's columnLayout. When provided, the cell will inherit minWidth from the corresponding column definition. | |
width | string | The width property specifies the width of a table's content area. This is a responsive property and you can have the options below available for you to use. '{ "rest": "value", "focus": "value", "active": "value", "hover": "value", "xs": "value", "md": "value", "lg": "value", "xl": "value", "xxl": "value" }' | |
maxWidth | string | The maxWidth property specifies the maxWidth of a table's content area. This is a responsive property and you can have the options below available for you to use. '{ "rest": "value", "focus": "value", "active": "value", "hover": "value", "xs": "value", "md": "value", "lg": "value", "xl": "value", "xxl": "value" }' | |
minWidth | string | The minWidth property specifies the minWidth of a table's content area. This is a responsive property and you can have the options below available for you to use. '{ "rest": "value", "focus": "value", "active": "value", "hover": "value", "xs": "value", "md": "value", "lg": "value", "xl": "value", "xxl": "value" }' | |
backgroundColor | 'neutral-background' | The backgroundColor property sets the background color of the table. This is a responsive property and you can have the options below available for you to use. '{ "rest": "value", "focus": "value", "active": "value", "hover": "value", "xs": "value", "md": "value", "lg": "value", "xl": "value", "xxl": "value" }' | |
padding | 'base' | The padding properties are used to generate space around an table's content area. This is a responsive property and you can have the options below available for you to use. '{ "rest": "value", "focus": "value", "active": "value", "hover": "value", "xs": "value", "md": "value", "lg": "value", "xl": "value", "xxl": "value" }' |
Table.Head
| Name | Type | Default | Description |
|---|---|---|---|
children* | React.ReactNode | The content of the table head. |
Table.Row
| Name | Type | Default | Description |
|---|---|---|---|
children* | React.ReactNode | The content of the table row. | |
id | string | The ID of the table row. | |
onClick | () => void; | Function to be passed when clicking on the table row. | |
width | string | The width property specifies the width of a table's content area. This is a responsive property and you can have the options below available for you to use. '{ "rest": "value", "focus": "value", "active": "value", "hover": "value", "xs": "value", "md": "value", "lg": "value", "xl": "value", "xxl": "value" }' | |
maxWidth | string | The maxWidth property specifies the maxWidth of a table's content area. This is a responsive property and you can have the options below available for you to use. '{ "rest": "value", "focus": "value", "active": "value", "hover": "value", "xs": "value", "md": "value", "lg": "value", "xl": "value", "xxl": "value" }' | |
minWidth | string | The minWidth property specifies the minWidth of a table's content area. This is a responsive property and you can have the options below available for you to use. '{ "rest": "value", "focus": "value", "active": "value", "hover": "value", "xs": "value", "md": "value", "lg": "value", "xl": "value", "xxl": "value" }' | |
backgroundColor | 'neutral-background' | The backgroundColor property sets the background color of the table. This is a responsive property and you can have the options below available for you to use. '{ "rest": "value", "focus": "value", "active": "value", "hover": "value", "xs": "value", "md": "value", "lg": "value", "xl": "value", "xxl": "value" }' | |
padding | 'base' | The padding properties are used to generate space around an table's content area. This is a responsive property and you can have the options below available for you to use. '{ "rest": "value", "focus": "value", "active": "value", "hover": "value", "xs": "value", "md": "value", "lg": "value", "xl": "value", "xxl": "value" }' |