Ir al contenido

Table

Componente de tabla con funciones avanzadas para mostrar datos tabulares.

import { Table } from 'asterui'
import type { ColumnType, RowSelection, ExpandableConfig, PaginationConfig } from 'asterui'

Tabla Básica

Tabla simple con datos.

Name
Email
Role
John Doejohn@example.comAdmin
Jane Smithjane@example.comUser
Bob Johnsonbob@example.comUser
Alice Williamsalice@example.comEditor
Charlie Browncharlie@example.comUser
import { Table } from 'asterui'

function App() {
  const userData = [
    { id: '1', name: 'John Doe', email: 'john@example.com', role: 'Admin' },
    { id: '2', name: 'Jane Smith', email: 'jane@example.com', role: 'User' },
    { id: '3', name: 'Bob Johnson', email: 'bob@example.com', role: 'User' },
    { id: '4', name: 'Alice Williams', email: 'alice@example.com', role: 'Editor' },
    { id: '5', name: 'Charlie Brown', email: 'charlie@example.com', role: 'User' },
  ];
  
  const columns = [
    { key: 'name', title: 'Name', dataIndex: 'name' },
    { key: 'email', title: 'Email', dataIndex: 'email' },
    { key: 'role', title: 'Role', dataIndex: 'role' },
  ];
  
  return (
      <Table columns={columns} dataSource={userData} pagination={false} />
    )
}

export default App

Renderizado Personalizado

Usa funciones de renderizado para etiquetas, botones y contenido personalizado.

Name
Email
Role
Status
Actions
John Doejohn@example.comAdminactive
Jane Smithjane@example.comUseractive
Bob Johnsonbob@example.comUserinactive
Alice Williamsalice@example.comEditoractive
import { Table, Tag, Button, Space } from 'asterui'

function App() {
  const userData = [
    { id: '1', name: 'John Doe', email: 'john@example.com', role: 'Admin', status: 'active' },
    { id: '2', name: 'Jane Smith', email: 'jane@example.com', role: 'User', status: 'active' },
    { id: '3', name: 'Bob Johnson', email: 'bob@example.com', role: 'User', status: 'inactive' },
    { id: '4', name: 'Alice Williams', email: 'alice@example.com', role: 'Editor', status: 'active' },
  ];
  
  const columns = [
    { key: 'name', title: 'Name', dataIndex: 'name', width: 150 },
    { key: 'email', title: 'Email', dataIndex: 'email' },
    { key: 'role', title: 'Role', dataIndex: 'role', align: 'center' },
    {
      key: 'status',
      title: 'Status',
      dataIndex: 'status',
      align: 'center',
      render: (value) => (
        <Tag color={value === 'active' ? 'success' : 'ghost'} size="sm">
          {String(value)}
        </Tag>
      ),
    },
    {
      key: 'actions',
      title: 'Actions',
      align: 'right',
      render: () => (
        <Space size="xs">
          <Button size="xs" variant="ghost">Edit</Button>
          <Button size="xs" variant="ghost">Delete</Button>
        </Space>
      ),
    },
  ];
  
  return (
      <Table columns={columns} dataSource={userData} pagination={false} />
    )
}

export default App

Filas Alternas

Rayas de cebra para mejor legibilidad.

Name
Email
Role
John Doejohn@example.comAdmin
Jane Smithjane@example.comUser
Bob Johnsonbob@example.comUser
Alice Williamsalice@example.comEditor
Charlie Browncharlie@example.comUser
import { Table } from 'asterui'

function App() {
  return (
      <Table columns={basicColumns} dataSource={userData.slice(0, 5)} striped pagination={false} />
    )
}

export default App

Tabla con Bordes

Añade bordes para una apariencia más definida.

Name
Email
Role
John Doejohn@example.comAdmin
Jane Smithjane@example.comUser
Bob Johnsonbob@example.comUser
Alice Williamsalice@example.comEditor
Charlie Browncharlie@example.comUser
import { Table } from 'asterui'

function App() {
  return (
      <Table columns={basicColumns} dataSource={userData.slice(0, 5)} bordered pagination={false} />
    )
}

export default App

Tamaño Compacto

Tamaño extra pequeño para datos densos.

Name
Email
Role
John Doejohn@example.comAdmin
Jane Smithjane@example.comUser
Bob Johnsonbob@example.comUser
Alice Williamsalice@example.comEditor
Charlie Browncharlie@example.comUser
import { Table } from 'asterui'

function App() {
  return (
      <Table
        columns={basicColumns}
        dataSource={userData.slice(0, 5)}
        size="xs"
        striped
        bordered
        pagination={false}
      />
    )
}

export default App

Tamaño Extra Grande

Tamaño extra grande para énfasis.

Name
Email
Role
John Doejohn@example.comAdmin
Jane Smithjane@example.comUser
Bob Johnsonbob@example.comUser
import { Table } from 'asterui'

function App() {
  return (
      <Table columns={basicColumns} dataSource={userData.slice(0, 3)} size="xl" pagination={false} />
    )
}

export default App

Estado Vacío

Mensaje de estado vacío personalizable.

Name
Email
Role
No users found
import { Table } from 'asterui'

function App() {
  const columns = [
    { key: 'name', title: 'Name', dataIndex: 'name' },
    { key: 'email', title: 'Email', dataIndex: 'email' },
    { key: 'role', title: 'Role', dataIndex: 'role' },
  ];
  
  return (
      <Table
        columns={columns}
        dataSource={[]}
        pagination={false}
        locale={{ emptyText: 'No users found' }}
      />
    )
}

export default App

Estado de Carga

Muestra un spinner de carga mientras se obtienen los datos.

Name
Email
Role
John Doejohn@example.comAdmin
Jane Smithjane@example.comUser
Bob Johnsonbob@example.comUser
Alice Williamsalice@example.comEditor
Charlie Browncharlie@example.comUser
import { Table, Button } from 'asterui'
import { useState } from 'react'

function App() {
  const [isLoading, setIsLoading] = useState(false);
  
  const columns = [
    { key: 'name', title: 'Name', dataIndex: 'name' },
    { key: 'email', title: 'Email', dataIndex: 'email' },
    { key: 'role', title: 'Role', dataIndex: 'role' },
  ];
  
  const userData = [
    { id: '1', name: 'John Doe', email: 'john@example.com', role: 'Admin' },
    { id: '2', name: 'Jane Smith', email: 'jane@example.com', role: 'User' },
    { id: '3', name: 'Bob Johnson', email: 'bob@example.com', role: 'User' },
    { id: '4', name: 'Alice Williams', email: 'alice@example.com', role: 'Editor' },
    { id: '5', name: 'Charlie Brown', email: 'charlie@example.com', role: 'User' },
  ];
  
  return (
      <div className="space-y-4">
        <Button size="sm" onClick={() => setIsLoading(!isLoading)}>
          {isLoading ? 'Hide' : 'Show'} Loading
        </Button>
        <Table columns={columns} dataSource={userData} loading={isLoading} pagination={false} />
      </div>
    )
}

export default App

Paginación Básica

Pagina conjuntos de datos grandes.

Name
Email
Role
John Doejohn@example.comAdmin
Jane Smithjane@example.comUser
Bob Johnsonbob@example.comUser
Alice Williamsalice@example.comEditor
Charlie Browncharlie@example.comUser
import { Table } from 'asterui'

function App() {
  return (
      <Table columns={basicColumns} dataSource={userData} pagination={{ pageSize: 5 }} />
    )
}

export default App

Paginación Avanzada

Selector de tamaño de página, salto rápido y visualización de total.

Name
Email
Role
John Doejohn@example.comAdmin
Jane Smithjane@example.comUser
Bob Johnsonbob@example.comUser
Alice Williamsalice@example.comEditor
Charlie Browncharlie@example.comUser
1-5 of 12 items
Go to
import { Table } from 'asterui'

function App() {
  return (
      <Table
        columns={basicColumns}
        dataSource={userData}
        pagination={{
          pageSize: 5,
          showSizeChanger: true,
          showQuickJumper: true,
          showTotal: (total, range) => `${range[0]}-${range[1]} of ${total} items`,
          pageSizeOptions: [5, 10, 20],
        }}
      />
    )
}

export default App

Encabezado Fijo

Mantiene el encabezado visible al desplazarse.

Name
Email
Role
John Doejohn@example.comAdmin
Jane Smithjane@example.comUser
Bob Johnsonbob@example.comUser
Alice Williamsalice@example.comEditor
Charlie Browncharlie@example.comUser
David Leedavid@example.comUser
Emma Wilsonemma@example.comEditor
Frank Millerfrank@example.comUser
Grace Taylorgrace@example.comAdmin
Henry Davishenry@example.comUser
Iris Martiniris@example.comEditor
Jack Whitejack@example.comUser
import { Table } from 'asterui'

function App() {
  return (
      <div className="max-h-64 overflow-auto border border-base-content/10 rounded-lg">
        <Table columns={basicColumns} dataSource={userData} pinRows striped pagination={false} />
      </div>
    )
}

export default App

Ordenación de Columnas

Haz clic en los encabezados de columna para ordenar los datos.

Name
Age
Email
Jane Smith28jane@example.com
Charlie Brown29charlie@example.com
John Doe32john@example.com
Alice Williams35alice@example.com
David Lee41david@example.com
Bob Johnson45bob@example.com
import { Table } from 'asterui'

function App() {
  const columns = [
    { key: 'name', title: 'Name', dataIndex: 'name', sorter: true },
    { key: 'age', title: 'Age', dataIndex: 'age', sorter: true, defaultSortOrder: 'ascend' },
    { key: 'email', title: 'Email', dataIndex: 'email', sorter: true },
  ];
  
  return (
      <Table
        columns={columns}
        dataSource={userData.slice(0, 6)}
        pagination={false}
      />
    )
}

export default App

Ordenación Controlada

Controla el estado de ordenación externamente.

Name
Email
Role
Alice Williamsalice@example.comEditor
Bob Johnsonbob@example.comUser
Charlie Browncharlie@example.comUser
Jane Smithjane@example.comUser
John Doejohn@example.comAdmin
import { Table, Button, Space } from 'asterui'
import { useState } from 'react'

function App() {
  const [sortOrder, setSortOrder] = useState<'ascend' | 'descend' | null>('ascend');
  
  const columns = [
    { key: 'name', title: 'Name', dataIndex: 'name', sorter: true, sortOrder },
    { key: 'email', title: 'Email', dataIndex: 'email' },
    { key: 'role', title: 'Role', dataIndex: 'role' },
  ];
  
  const userData = [
    { id: '1', name: 'John Doe', email: 'john@example.com', role: 'Admin' },
    { id: '2', name: 'Jane Smith', email: 'jane@example.com', role: 'User' },
    { id: '3', name: 'Bob Johnson', email: 'bob@example.com', role: 'User' },
    { id: '4', name: 'Alice Williams', email: 'alice@example.com', role: 'Editor' },
    { id: '5', name: 'Charlie Brown', email: 'charlie@example.com', role: 'User' },
  ];
  
  return (
      <div className="space-y-4">
        <Space size="sm">
          <Button size="sm" variant={sortOrder === 'ascend' ? 'primary' : 'outline'} onClick={() => setSortOrder('ascend')}>
            Ascending
          </Button>
          <Button size="sm" variant={sortOrder === 'descend' ? 'primary' : 'outline'} onClick={() => setSortOrder('descend')}>
            Descending
          </Button>
          <Button size="sm" variant={sortOrder === null ? 'primary' : 'outline'} onClick={() => setSortOrder(null)}>
            None
          </Button>
        </Space>
        <Table
          columns={columns}
          dataSource={userData}
          pagination={false}
          onSortChange={(sorter) => setSortOrder(sorter.order ?? null)}
        />
      </div>
    )
}

export default App

Filtrado de Columnas

Añade desplegables de filtro a las columnas.

Name
Role
Status
John DoeAdminactive
Jane SmithUseractive
Bob JohnsonUserinactive
Alice WilliamsEditoractive
Charlie BrownUseractive
David LeeUseractive
import { Table } from 'asterui'

function App() {
  const columns = [
    { key: 'name', title: 'Name', dataIndex: 'name' },
    {
      key: 'role',
      title: 'Role',
      dataIndex: 'role',
      filters: [
        { text: 'Admin', value: 'Admin' },
        { text: 'User', value: 'User' },
        { text: 'Editor', value: 'Editor' },
      ],
      onFilter: (value, record) => record.role === value,
    },
    {
      key: 'status',
      title: 'Status',
      dataIndex: 'status',
      filters: [
        { text: 'Active', value: 'active' },
        { text: 'Inactive', value: 'inactive' },
      ],
      onFilter: (value, record) => record.status === value,
    },
  ];
  
  return (
      <Table
        columns={columns}
        dataSource={userData.slice(0, 6)}
        pagination={false}
      />
    )
}

export default App

Selección con Checkbox

Habilita la selección de filas con checkboxes.

Selected: None
Name
Email
Role
John Doejohn@example.comAdmin
Jane Smithjane@example.comUser
Bob Johnsonbob@example.comUser
Alice Williamsalice@example.comEditor
Charlie Browncharlie@example.comUser
import { Table } from 'asterui'
import { useState } from 'react'

function App() {
  const [selectedKeys, setSelectedKeys] = useState<React.Key[]>([]);
  
  const columns = [
    { key: 'name', title: 'Name', dataIndex: 'name' },
    { key: 'email', title: 'Email', dataIndex: 'email' },
    { key: 'role', title: 'Role', dataIndex: 'role' },
  ];
  
  const userData = [
    { id: '1', name: 'John Doe', email: 'john@example.com', role: 'Admin' },
    { id: '2', name: 'Jane Smith', email: 'jane@example.com', role: 'User' },
    { id: '3', name: 'Bob Johnson', email: 'bob@example.com', role: 'User' },
    { id: '4', name: 'Alice Williams', email: 'alice@example.com', role: 'Editor' },
    { id: '5', name: 'Charlie Brown', email: 'charlie@example.com', role: 'User' },
  ];
  
  return (
      <div className="space-y-4">
        <div className="text-sm">Selected: {selectedKeys.join(', ') || 'None'}</div>
        <Table
          columns={columns}
          dataSource={userData}
          rowSelection={{
            selectedRowKeys: selectedKeys,
            onChange: (keys) => setSelectedKeys(keys),
          }}
          pagination={false}
        />
      </div>
    )
}

export default App

Selección con Radio

Selección de una sola fila con botones de radio.

Selected: None
Name
Email
Role
John Doejohn@example.comAdmin
Jane Smithjane@example.comUser
Bob Johnsonbob@example.comUser
Alice Williamsalice@example.comEditor
Charlie Browncharlie@example.comUser
import { Table } from 'asterui'
import { useState } from 'react'

function App() {
  const [selectedKeys, setSelectedKeys] = useState<React.Key[]>([]);
  
  const columns = [
    { key: 'name', title: 'Name', dataIndex: 'name' },
    { key: 'email', title: 'Email', dataIndex: 'email' },
    { key: 'role', title: 'Role', dataIndex: 'role' },
  ];
  
  const userData = [
    { id: '1', name: 'John Doe', email: 'john@example.com', role: 'Admin' },
    { id: '2', name: 'Jane Smith', email: 'jane@example.com', role: 'User' },
    { id: '3', name: 'Bob Johnson', email: 'bob@example.com', role: 'User' },
    { id: '4', name: 'Alice Williams', email: 'alice@example.com', role: 'Editor' },
    { id: '5', name: 'Charlie Brown', email: 'charlie@example.com', role: 'User' },
  ];
  
  return (
      <div className="space-y-4">
        <div className="text-sm">Selected: {selectedKeys.join(', ') || 'None'}</div>
        <Table
          columns={columns}
          dataSource={userData}
          rowSelection={{
            type: 'radio',
            selectedRowKeys: selectedKeys,
            onChange: (keys) => setSelectedKeys(keys),
          }}
          pagination={false}
        />
      </div>
    )
}

export default App

Filas Expandibles

Expande filas para mostrar contenido adicional.

Expand
Name
Email
Role
John Doejohn@example.comAdmin
Jane Smithjane@example.comUser
Bob Johnsonbob@example.comUser
Alice Williamsalice@example.comEditor
Charlie Browncharlie@example.comUser
import { Table } from 'asterui'

function App() {
  const columns = [
    { key: 'name', title: 'Name', dataIndex: 'name' },
    { key: 'email', title: 'Email', dataIndex: 'email' },
    { key: 'role', title: 'Role', dataIndex: 'role' },
  ];
  
  const userData = [
    { id: '1', name: 'John Doe', email: 'john@example.com', role: 'Admin', status: 'active', age: 32, description: 'Senior administrator' },
    { id: '2', name: 'Jane Smith', email: 'jane@example.com', role: 'User', status: 'active', age: 28, description: 'Regular user' },
    { id: '3', name: 'Bob Johnson', email: 'bob@example.com', role: 'User', status: 'inactive', age: 45, description: 'Account suspended' },
    { id: '4', name: 'Alice Williams', email: 'alice@example.com', role: 'Editor', status: 'active', age: 35, description: 'Content editor' },
    { id: '5', name: 'Charlie Brown', email: 'charlie@example.com', role: 'User', status: 'active', age: 29, description: 'New user' },
  ];
  
  const expandable = {
    expandedRowRender: (record) => (
      <div className="p-2">
        <p className="text-sm"><strong>Description:</strong> {record.description}</p>
        <p className="text-sm"><strong>Age:</strong> {record.age}</p>
      </div>
    ),
    rowExpandable: (record) => record.status === 'active',
  };
  
  return (
      <Table
        columns={columns}
        dataSource={userData}
        expandable={expandable}
        pagination={false}
      />
    )
}

export default App

Texto con Elipsis

Trunca texto largo con elipsis.

Name
Email
Description
John Doejohn@example.comSenior administrator with full system access
Jane Smithjane@example.comRegular user account
Bob Johnsonbob@example.comAccount currently suspended
Alice Williamsalice@example.comContent editor with publishing rights
import { Table } from 'asterui'

function App() {
  const columns = [
    { key: 'name', title: 'Name', dataIndex: 'name', width: 100 },
    { key: 'email', title: 'Email', dataIndex: 'email', width: 150, ellipsis: true },
    { key: 'description', title: 'Description', dataIndex: 'description', ellipsis: true },
  ];
  
  const userData = [
    { id: '1', name: 'John Doe', email: 'john@example.com', description: 'Senior administrator with full system access' },
    { id: '2', name: 'Jane Smith', email: 'jane@example.com', description: 'Regular user account' },
    { id: '3', name: 'Bob Johnson', email: 'bob@example.com', description: 'Account currently suspended' },
    { id: '4', name: 'Alice Williams', email: 'alice@example.com', description: 'Content editor with publishing rights' },
  ];
  
  return (
      <Table
        columns={columns}
        dataSource={userData}
        pagination={false}
      />
    )
}

export default App

Configuración de Desplazamiento

Establece ancho y alto máximo con desplazamiento.

Name
Email
Role
Status
Age
Description
John Doejohn@example.comAdminactive32Senior administrator
Jane Smithjane@example.comUseractive28Regular user
Bob Johnsonbob@example.comUserinactive45Account suspended
Alice Williamsalice@example.comEditoractive35Content editor
Charlie Browncharlie@example.comUseractive29New user
import { Table } from 'asterui'

function App() {
  const columns = [
    { key: 'name', title: 'Name', dataIndex: 'name', width: 150 },
    { key: 'email', title: 'Email', dataIndex: 'email', width: 200 },
    { key: 'role', title: 'Role', dataIndex: 'role', width: 100 },
    { key: 'status', title: 'Status', dataIndex: 'status', width: 100 },
    { key: 'age', title: 'Age', dataIndex: 'age', width: 80 },
    { key: 'description', title: 'Description', dataIndex: 'description', width: 300 },
  ];
  
  const userData = [
    { id: '1', name: 'John Doe', email: 'john@example.com', role: 'Admin', status: 'active', age: 32, description: 'Senior administrator' },
    { id: '2', name: 'Jane Smith', email: 'jane@example.com', role: 'User', status: 'active', age: 28, description: 'Regular user' },
    { id: '3', name: 'Bob Johnson', email: 'bob@example.com', role: 'User', status: 'inactive', age: 45, description: 'Account suspended' },
    { id: '4', name: 'Alice Williams', email: 'alice@example.com', role: 'Editor', status: 'active', age: 35, description: 'Content editor' },
    { id: '5', name: 'Charlie Brown', email: 'charlie@example.com', role: 'User', status: 'active', age: 29, description: 'New user' },
  ];
  
  return (
      <Table
        columns={columns}
        dataSource={userData}
        scroll={{ x: 800, y: 200 }}
        pagination={false}
      />
    )
}

export default App

Ejemplo Completo

Tabla con múltiples funciones combinadas.

Name
Email
Role
Status
Actions
John Doejohn@example.comAdminactive
Jane Smithjane@example.comUseractive
Bob Johnsonbob@example.comUserinactive
Alice Williamsalice@example.comEditoractive
Charlie Browncharlie@example.comUseractive
import { Table, Tag, Button, Space } from 'asterui'

function App() {
  return (
      <Table
        columns={columnsWithRender}
        dataSource={userData}
        size="sm"
        striped
        bordered
        pagination={{ pageSize: 5 }}
      />
    )
}

export default App
PropiedadDescripciónTipoPredeterminado
columnsConfiguración de columnas de la tablaColumnType<T>[]-
dataSourceDatos a mostrar en la tablaT[]-
rowKeyClave única para cada filakeyof T | ((record: T) => string)'id'
loadingEstado de cargabooleanfalse
sizeTamaño de la tabla'xs' | 'sm' | 'md' | 'lg' | 'xl''md'
borderedAñadir borde alrededor de la tablabooleanfalse
hoverableResaltar fila al pasar el cursorbooleantrue
stripedColores de fila alternos (rayas de cebra)booleanfalse
pinRowsFijar filas de encabezado al desplazarsebooleanfalse
pinColsFijar columnas al desplazarsebooleanfalse
paginationConfiguración de paginación o false para deshabilitarfalse | PaginationConfig{ pageSize: 10 }
rowSelectionConfiguración de selección de filasRowSelection<T>-
expandableConfiguración de filas expandiblesExpandableConfig<T>-
scrollConfiguración de desplazamiento para dimensiones fijasScrollConfig-
classNameClases CSS adicionalesstring-
onRowManejadores de eventos de fila(record: T, index: number) => HTMLAttributes-
onChangeCallback unificado para paginación, ordenación y filtrado(pagination, filters, sorter, extra) => void-
onSortChangeCallback cuando cambia la ordenación(sorter: SorterResult<T>) => void-
onFilterChangeCallback cuando cambia el filtro(filters: Record<string, ...>) => void-
localeConfiguración de localización para texto vacío, etiquetas de filtro{ emptyText?, filterConfirm?, filterReset?, selectAll? }-
data-testidID de prueba para el componentestring'table'
aria-labelEtiqueta accesible para la tablastring-
PropiedadDescripciónTipoPredeterminado
keyClave única para la columnastring-
titleTítulo del encabezado de columnaReactNode-
dataIndexNombre del campo en el registro de datoskeyof T-
renderFunción de renderizado personalizada para el contenido de la celda(value, record, index) => ReactNode-
widthAncho de columnastring | number-
alignAlineación del texto'left' | 'center' | 'right''left'
fixedFijar columna a izquierda o derecha'left' | 'right'-
sorterHabilitar ordenación o función de ordenación personalizadaboolean | ((a: T, b: T) => number)-
sortOrderOrden de ordenación controlado'ascend' | 'descend' | null-
defaultSortOrderOrden de ordenación predeterminado'ascend' | 'descend'-
filtersConfiguración de desplegable de filtroFilterConfig[]-
filteredValueValores filtrados controlados(string | number | boolean)[]-
defaultFilteredValueValores filtrados predeterminados(string | number | boolean)[]-
onFilterFunción de filtro(value, record) => boolean-
ellipsisTruncar texto con elipsisbooleanfalse
hiddenOcultar columnabooleanfalse
PropiedadDescripciónTipoPredeterminado
typeTipo de selección'checkbox' | 'radio''checkbox'
selectedRowKeysClaves de fila seleccionadas controladasReact.Key[]-
onChangeCallback cuando cambia la selección(selectedRowKeys, selectedRows) => void-
getCheckboxPropsFunción para personalizar propiedades del checkbox(record) => { disabled?, name? }-
PropiedadDescripciónTipoPredeterminado
expandedRowRenderFunción de renderizado para contenido expandido(record, index, expanded) => ReactNode-
expandedRowKeysClaves de fila expandidas controladasReact.Key[]-
defaultExpandedRowKeysClaves de fila expandidas predeterminadasReact.Key[]-
rowExpandableFunción para determinar si la fila es expandible(record) => boolean-
onExpandCallback cuando cambia el estado de expansión(expanded, record) => void-
onExpandedRowsChangeCallback cuando cambian las claves expandidas(expandedKeys) => void-
expandRowByClickExpandir fila al hacer clic en la filabooleanfalse
expandIconIcono de expansión personalizado(props) => ReactNode-
PropiedadDescripciónTipoPredeterminado
currentNúmero de página actualnumber1
pageSizeNúmero de elementos por páginanumber10
totalNúmero total de elementos (para paginación del lado del servidor)number-
showSizeChangerMostrar desplegable de tamaño de páginabooleanfalse
showQuickJumperMostrar entrada de salto rápido de páginabooleanfalse
showTotalFunción para renderizar texto del total(total, range) => ReactNode-
pageSizeOptionsOpciones de tamaño de páginanumber[][10, 20, 50, 100]
positionPosición de la paginación'topLeft' | 'topCenter' | 'topRight' | 'bottomLeft' | 'bottomCenter' | 'bottomRight''bottomRight'
onChangeCallback cuando cambia la página(page, pageSize) => void-
onShowSizeChangeCallback cuando cambia el tamaño de página(current, size) => void-
  • Usa <table> semántica con role="grid"
  • Los encabezados de columna incluyen role="columnheader" y aria-sort para columnas ordenables
  • Los checkboxes de selección de fila tienen aria-label adecuado
  • Los controles de ordenación son accesibles por teclado (Enter/Space para alternar)
  • Los desplegables de filtro soportan la tecla Escape para cerrar
  • Los botones de paginación incluyen aria-label y aria-current
  • Los botones de expandir/contraer incluyen aria-expanded
  • Estado de checkbox indeterminado para selección parcial

El componente expone atributos data-testid:

  • {baseTestId} - Contenedor raíz
  • {baseTestId}-table - Elemento de tabla
  • {baseTestId}-header-{columnKey} - Encabezados de columna
  • {baseTestId}-row-{index} - Filas de tabla
  • {baseTestId}-row-{index}-{columnKey} - Celdas de tabla
  • {baseTestId}-row-{index}-select - Checkbox de selección de fila
  • {baseTestId}-row-{index}-expanded - Contenido de fila expandida
  • {baseTestId}-select-all - Checkbox de seleccionar todo
  • {baseTestId}-pagination - Contenedor de paginación
  • {baseTestId}-prev, {baseTestId}-next - Botones de paginación
  • {baseTestId}-{columnKey}-filter-button - Botón de filtro
  • {baseTestId}-empty - Estado vacío
  • {baseTestId}-loading - Estado de carga

Atributos de datos:

  • data-state="selected" - En filas seleccionadas