ValyroUI English version

Data Table

Таблицы с поиском и сортировкой. Бесплатно, MIT · Данные и показатели › Таблицы

Установка

npx valyro-cli@latest add data-table
npx shadcn@latest add https://valyro.xyz/r/data-table.json
npm install valyro-ui

import 'valyro-ui/styles.css';
import { DataTable } from 'valyro-ui';

Пропсы

PropTypeDefault
datareadonly T[]All rows; search, sorting and pagination run on this array in the browser. Or rows as children (see children).
columnsreadonly DataTableColumn<T>[]Column definitions: header, value accessor, cell renderer, sorting, alignment and width.
childrenReactNodeThe compound form instead of data and columns: a DataTable.Header of DataTable.Columns and a DataTable.Body of DataTable.Rows with a DataTable.Cell per column. Search, sorting and selection work on the cells' value (or their text); onRowClick gets a DataTableRowData.
getRowId(row: T, index: number) => stringStable id for selection and keys. Defaults to row.id, then the row's index in data.
labelstringAccessible name of the table.
searchablebooleanfalseShows a search field that filters rows across all columns.
pageSizenumberRows per page. Omit to show every row.
sortSortState | nullControlled sort; use with onSortChange.
defaultSortSortState | nullnullInitial sort when uncontrolled.
onSortChange(sort: SortState | null) => voidCalled with the new sort when it changes.
selectablebooleanfalseAdds a checkbox column.
selectedstring[]Controlled selected; use with onSelectedChange.
defaultSelectedstring[][]Initial selected when uncontrolled.
onSelectedChange(ids: string[]) => voidCalled with the new selected when it changes.
onRowClick(row: T) => voidMakes rows clickable and focusable; Enter on a focused row calls it too.
loadingbooleanfalseSkeleton rows (pageSize or 5) replace the body, and the select-all and paging buttons are disabled.
density'comfortable' | 'compact''comfortable'Row height and text size: compact has tighter cells and smaller text.
maxHeightCSSProperties['maxHeight']Limits the height; the body scrolls under a pinned header.
virtualizebooleanfalseRenders only the rows scrolled into view, for thousands of rows without pagination. Needs maxHeight; rows should share one height (the first rendered row is measured).
stickyFirstColumnbooleantrueKeeps the first column (and the checkbox column) in view while scrolling sideways.
emptyReactNodeReplaces the default empty state.
localestringLocale for default number/date cells and counters. Defaults to the ThemeProvider locale, then the browser's.
labelsPartial<DataTableLabels>Overrides for the built-in English text; keys left out keep their defaults.

Составные части

DataTable.Header (DataTableHeader), DataTable.Column (DataTableColumnPart), DataTable.Body (DataTableBody), DataTable.Row (DataTableRow), DataTable.Cell (DataTableCell)

Похожие компоненты

  • Data Grid — Таблица на 100 000 строк: группировка, фильтры, редактирование
  • Virtual List — Виртуальный список на 100 000 строк
  • Bulk Action Bar — Панель действий над выбранными строками с горячими клавишами
  • List Block — Блок списка с картинками или иконками, описанием и значением
  • Description List — Список «ключ — значение»: столбиком, строками или сеткой с иконками
  • Tree View — Древовидные структуры
  • Accordion — Раскрывающиеся секции
  • Sortable — Сортировка перетаскиванием
  • JSON Viewer — Просмотр JSON
  • Timeline — Хронология событий
  • Card — Универсальные карточки
  • Item Card — Карточка-строка: иконка, заголовок, описание и элемент управления справа

Назад: Filter Toolbar · Далее: Data Grid · Весь раздел «Данные и показатели»