C
Cassa UI

Table

Generic typed table from @cassa/ui-data. Client-side sort, search, and pagination built in. Column keys are type-safe against your data shape.

Import

import { Table, type Column } from '@cassa/ui-data'

Basic usage

NameEmailRole
Alice Johnsonalice@example.comAdmin
Bob Smithbob@example.comDeveloper
Carol Whitecarol@example.comDesigner
Dave Browndave@example.comDeveloper
Eve Daviseve@example.comManager

Searchable with custom render

NameEmailRoleStatus
Alice Johnsonalice@example.comAdminactive
Bob Smithbob@example.comDeveloperactive
Carol Whitecarol@example.comDesignerpending
Dave Browndave@example.comDeveloperinactive
1–4 of 5

Loading skeleton

NameEmailRoleStatus

Full example

import { Table, type Column } from '@cassa/ui-data'
import { Badge } from '@cassa/ui'

type User = { id: number; name: string; email: string; status: string }

const columns: Column<User>[] = [
  { key: 'name', header: 'Name', sortable: true },
  { key: 'email', header: 'Email', sortable: true },
  {
    key: 'status',
    header: 'Status',
    render: (row) => (
      <Badge colorScheme={row.status === 'active' ? 'success' : 'neutral'}>
        {row.status}
      </Badge>
    ),
  },
]

export const UsersTable = ({ users }: { users: User[] }) => (
  <Table columns={columns} data={users} searchable pageSize={10} />
)

Table props

PropTypeDefaultDescription
columns*Column<T>[]Column definitions — key, header, sortable, render, width.
data*T[]Array of row objects. T must extend Record<string, unknown>.
loadingbooleanfalseShows animated skeleton rows while data is loading.
searchablebooleanfalseAdds a search input that filters across all string columns.
pageSizenumber5Rows per page.
emptyMessagestring"No results found."Message shown when data is empty or no rows match.

Column definition

PropTypeDefaultDescription
key*keyof TProperty key on the row object — type-safe against your data shape.
header*stringColumn header label.
sortablebooleanClick header to sort: asc → desc → unsorted.
render(row: T, index: number) => ReactNodeCustom cell renderer. Defaults to String(row[key]).
widthstringTailwind width class, e.g. "w-32".