Command palette

@yasinsensoy/native

React Native · Components

Table

Data table (same API as web).

7 exports

Live example

The preview runs in the browser with the web component; the native component takes the same props and looks the same on iOS and Android.

Preview

Recent orders
OrdersStatus
#1027Can ÖztürkPaidOct 9, 2026$980.00
#1026Zeynep DemirPaidOct 4, 2026$250.00
#1025Mehmet KayaPendingOct 3, 2026$1,420.00
#1024Ayşe YılmazPaidOct 1, 2026$250.00
Total2900

Code

import { TableSort, Table, Badge } from "@yasinsensoy/native";

const [sort, setSort] = useState<TableSort | null>(null);

<Table
  label="Orders"
  rows={orders}
  caption="Recent
  orders"
  sort={sort}
  onSortChange={setSort}
  columns={[
    { key: "id", header: "Order" },
    { key: "customer", header: "Customer", sortable: true },
    { key: "paid", header: "Status", render: (s) => <Badge tone={s.paid ? "success" : "warning"}>…</Badge> },
    { key: "date", header: "Date", format: "date", hideOnMobile: true },
    { key: "total", header: "Amount", tooltip: "VAT included, shipping excluded", format: "currency", sortable: true },
  ]}
  footer={{ customer: "Toplam", total: total }}
/>

Events

  1. Events appear here when you interact with the preview.

Import

import { Table } from "@yasinsensoy/native";

Table

component

Data table (same API as web). Columns come via columns, rows via rows; header, cells, card view, formatting, sorting and pagination come built in.

  • Column widths are estimated from content (no measuring, no flicker); if the table is wider than the screen it scrolls horizontally, if narrower the columns widen proportionally.
  • On phones each row turns into a card (stackOnMobile), with the column name before each value.
  • With format, numbers, currency, percentages and dates are formatted by locale; numbers are right-aligned with tabular digits.
  • Sorting is controlled (sort + onSortChange) or uncontrolled.
  • For large data (thousands of rows, editing, filters) use DataGrid.
Table({ columns, rows, rowKey, caption, empty: emptyProp, footer, stackOnMobile, stickyHeader, maxHeight, label, sort: sortProp, defaultSort, onSortChange, onRowPress, selectedKey, locale: localeProp, currency: currencyProp, pagination, styles, style, testID, }: TableProps<T>): JSX.Element

Examples

<Table
  rows={orders}
  columns={[
    { key: "no", header: "Order" },
    { key: "status", header: "Status", render: (o) => <Badge tone="success">{o.status}</Badge> },
    { key: "amount", header: "Amount", format: "currency", sortable: true },
  ]}
  footer={{ no: "Total", amount: "$1,250.00" }}
/>

Built-in formats of a cell value. Numbers are formatted by locale.

type TableFormat = "number" | "currency" | "percent" | "date" | "datetime"

TableColumn

interface

A Table column (same fields as web).

NameTypeDescription
keystringColumn id; if value is omitted, the value of this field in the row is shown.
headerReactNodeHeader cell.
tooltip?TooltipPropTooltip shown with ⓘ next to the header (on long press).
mobileLabel?stringName written before the value in card view. Defaults to the text header.
value?(row: T) => unknownProduces the cell value from the row (sorting and formatting use it too).
render?(row: T, index: number) => ReactNodeFully customizes the cell content (e.g. a badge, a button).
format?TableFormatBuilt-in format: number, currency, percent (0.25 → 25%), date.
align?"start" | "center" | "end"Alignment. Defaults to "end" for numeric formats.
sortable?booleanCan be sorted by this column by tapping the header.
width?number | `${number}%`Column width: dp or percent ("20%"). If omitted it is estimated from the content (140 for render columns); if the table is narrower than the screen columns widen proportionally, if wider it scrolls horizontally.
hideOnMobile?booleanHidden in card view.
style?StyleProp<ViewStyle>Style of this column's cells.

TableSort

interface

Sort state.

NameTypeDescription
keystringkey of the sorted column.
direction"asc" | "desc"Direction.

TableStyles

interface

Styles of the Table inner parts (counterpart of classNames on web).

NameTypeDescription
container?StyleProp<ViewStyle>Scroll container.
header?StyleProp<ViewStyle>Header row.
row?StyleProp<ViewStyle>Each data row (each card in card view).
footer?StyleProp<ViewStyle>Footer (totals) row.
wrapper?StyleProp<ViewStyle>Container wrapping the table and the pagination.

The Table pagination prop: same as PaginationProps. If total (or pageCount, hasNext) is omitted, rows is the full record set and the table slices the current page itself after sorting (it also keeps the page state); if given, rows is only that page.

type TablePagination = PaginationProps

TableProps

interface

Props of the Table component.

NameTypeDefaultDescription
columnsreadonly TableColumn<T>[]Columns.
rowsreadonly T[]Rows.
rowKey?keyof T | ((row: T, index: number) => string | number)Unique row key: a field name or a function. Defaults to id, then the index.
caption?ReactNodeCaption under the table (on top in card view).
empty?ReactNodethe `tableEmpty` text (`"Kayıt yok"`)Content shown when there are no rows.
footer?Partial<Record<string, ReactNode>>Footer row content by column key (e.g. totals).
stackOnMobile?booleantrueTurns each row into a card on narrow screens (below 640 dp).
stickyHeader?booleanThe header row stays on top during vertical scrolling; use with maxHeight.
maxHeight?numberMaximum height of the table body; beyond it rows scroll inside.
label?stringScreen reader name.
sort?TableSort | nullSorting (controlled). If omitted the table keeps the state itself (defaultSort).
defaultSort?TableSort | nullInitial sorting (uncontrolled).
onSortChange?(sort: TableSort | null) => voidCalled with the new sorting when a sortable header is tapped.
onRowPress?(row: T, index: number) => voidMakes rows pressable (e.g. go to details). onRowClick on web.
selectedKey?string | number | nullThe row with this key looks selected.
locale?string{@link UIProvider} `localeLocale used for formatting.
currency?string{@link UIProvider} `currencyCurrency.
pagination?TablePaginationPagination below the table. See TablePagination.
styles?TableStylesStyles of the inner parts.
style?StyleProp<ViewStyle>Container style.
testID?stringTest id.