Components
Table

Table

The Table component provides you with data tables with sorting, pagination, and selection.

Import

import { Table } from '@nostromo/ui-core'
// or
import { Table } from '@nostromo/ui-core/table'

Usage

import { Table } from '@nostromo/ui-core'
 
interface User {
  id: string
  name: string
  email: string
}
 
export default function Example() {
  const data: User[] = [
    { id: '1', name: 'John Doe', email: 'john@example.com' },
    { id: '2', name: 'Jane Smith', email: 'jane@example.com' }
  ]
  
  const columns = [
    { key: 'name', title: 'Name', dataIndex: 'name' },
    { key: 'email', title: 'Email', dataIndex: 'email' }
  ]
  
  return <Table data={data} columns={columns} />
}

Live Examples

Live Example
☀️
Copy
Storybook →
View Code
import { Table } from '@nostromo/ui-core' export default function TableDefault() { const data = [ { id: '1', name: 'John Doe', email: 'john@example.com' }, { id: '2', name: 'Jane Smith', email: 'jane@example.com' }, { id: '3', name: 'Bob Johnson', email: 'bob@example.com' } ] const columns = [...
Live Example
☀️
Copy
Storybook →
View Code
import { Table } from '@nostromo/ui-core' export default function TableStriped() { const data = [ { id: '1', name: 'John Doe', email: 'john@example.com' }, { id: '2', name: 'Jane Smith', email: 'jane@example.com' }, { id: '3', name: 'Bob Johnson', email: 'bob@example.com' } ] const columns = [...
Live Example
☀️
Copy
Storybook →
View Code
import { Table } from '@nostromo/ui-core' export default function TableBordered() { const data = [ { id: '1', name: 'John Doe', email: 'john@example.com' }, { id: '2', name: 'Jane Smith', email: 'jane@example.com' }, { id: '3', name: 'Bob Johnson', email: 'bob@example.com' } ] const columns = [...

Advanced Examples

With Sorting

Live Example
☀️
Copy
Storybook →
View Code
import { Table } from '@nostromo/ui-core' interface User { id: string name: string email: string } export default function SortableTable() { const [sortColumn, setSortColumn] = React.useState<string>()...

With Pagination

Live Example
☀️
Copy
Storybook →
View Code
import { Table } from '@nostromo/ui-core' export default function PaginatedTable() { const [currentPage, setCurrentPage] = React.useState(1) const [pageSize, setPageSize] = React.useState(10) const data = Array.from({ length: 100 }, (_, i) => ({ id: i + 1, name: `User ${i + 1}`, email: `user${i + 1}@example.com`...

Props

Table

PropTypeDefaultRequiredDescription
dataT[]-YesArray of data objects
columnsTableColumn<T>[]-YesColumn definitions
variant"default" | "striped" | "bordered" | "hover" | "elevated" | "interactive""default"NoVisual variant of the table
size"sm" | "md" | "lg""md"NoSize of table cells
loadingbooleanfalseNoWhether the table is loading
emptyTextstring"No data"NoText to show when no data
captionstringundefinedNoTable caption (for accessibility)
classNamestringundefinedNoAdditional CSS classes
rowKeykeyof T | ((record: T) => string | number)"id"NoUnique key for each row
onRowClick(record: T, index: number) => voidundefinedNoCallback when row is clicked
onSort(column: TableColumn<T>, direction: 'asc' | 'desc') => voidundefinedNoCallback when column is sorted
sortColumnstringundefinedNoCurrently sorted column (controlled)
sortDirection'asc' | 'desc'undefinedNoSort direction (controlled)
paginationPaginationPropsundefinedNoPagination configuration
selectionSelectionPropsundefinedNoRow selection configuration

TableColumn

PropTypeDefaultRequiredDescription
keystring-YesUnique column key
titlestring-YesColumn header text
dataIndexkeyof TundefinedNoProperty name in data object
render(value: unknown, record: T, index: number) => React.ReactNodeundefinedNoCustom render function
sortablebooleanfalseNoWhether column is sortable
widthstring | numberundefinedNoColumn width
align'left' | 'center' | 'right''left'NoText alignment
classNamestringundefinedNoAdditional CSS classes

PaginationProps

PropTypeDefaultRequiredDescription
currentnumber-YesCurrent page number
pageSizenumber-YesNumber of items per page
totalnumber-YesTotal number of items
onChange(page: number, pageSize: number) => void-YesCallback when page changes
showSizeChangerbooleanfalseNoWhether to show page size changer
showQuickJumperbooleanfalseNoWhether to show quick jumper

SelectionProps

PropTypeDefaultRequiredDescription
selectedRowKeys(string | number)[]-YesArray of selected row keys
onChange(selectedRowKeys: (string | number)[], selectedRows: T[]) => void-YesCallback when selection changes
getCheckboxProps(record: T) => { disabled?: boolean }undefinedNoFunction to get checkbox props for each row