Hulian UIv0.93.5413 components0 components
  • Start
  • Components
  • Blocks
  • Pages
  • Demos
  • Changelog
ChineseEnglish
  • ComponentsComponents
  • ThemeTheme

Collections

  • QuestionCard
  • Table
  • Book3D
  • ProTable
  • PricingTable
  • JsonViewer
  • EditableTable
  • List
  • Descriptions
  • RowActions
  • Tree
  • Card
  • Carousel
  • Video
  • Audio
  • BentoGrid
  • Image
  • MagicCard
  • AnimatedList
  • Marquee
  • Sortable
  • Kanban
  • DesignCanvas
  • LayerTree
  • StageDraw
  • SlideDeck
  • PresenterView
  • ComponentPicker
  • EventStream
  • QueueLane
  • DocumentSheet
  • Novel reader
  • Scheduler
  • Org classroom
  • Danmaku
  • LiveChat
  • LivePlayer
  • LogViewer
  • FileTree
  • CodeReviewThread
  • VirtualList
  • InfiniteScroll
  • LogoLoop
  • BounceCards
  • CardSwap
  • ChromaGrid
  • CircularGallery
  • DomeGallery
  • FlyingPosters
  • InfiniteMenu
  • MagicBento
  • ScrollStack
  • ProfileCard
  • TiltedCard
  • PixelCard
  • DecayCard
  • ReflectiveCard
  • Folder

Charts and Diagrams

  • Flow
  • Diagram
  • Paper
  • SequenceDiagram
  • Sankey
  • Sparkline
  • Funnel
  • Treemap
  • Gantt
  • Heatmap
  • ContributionGraph
  • Legend
  • Chart
  • WorldMap

Information

  • ImageViewer
  • LiveProductCard
  • DiffStat
  • ScoreRing
  • ScoreScale
  • Badge
  • Dot
  • StatusDot
  • Chip
  • FilterChip
  • Coupon
  • Tag
  • Annotation
  • Avatar
  • AvatarCircles
  • User
  • QRCode
  • Comment
  • RelativeTime
  • GitCommit
  • DeployStatus
  • ShieldBadge
  • AwardBadge
  • CreditCard
  • IconTile

Metrics

  • Stat
  • Statistic
  • Meter
  • Timeline
  • NumberTicker

Placeholders

  • Empty
  • Skeleton
  • Watermark

ProTable

pro-table

Combines business-table columns, querying, sorting, selection, pagination, and toolbar actions.

Usage

Hosted Mode

Pass request, that is, ProTable will manage page/sort/filters/loading/data by itself and request the server on demand.

Hosting mode (server request)
No data
0 items
tsx
const request = async (p) => {
  const rows = await fetchEmployees(p.filters, p.sort);
  const start = (p.page - 1) * p.pageSize;
  return { data: rows.slice(start, start + p.pageSize), total: rows.length };
};

<ProTable
  title="Employee List"
  columns={columns}
  request={request}
  defaultPageSize={8}
  enableRowSelection
  search={{ fields: searchFields }}
/>

Default sorting + fixed query parameters

defaultSorting allows request to be sorted for the first time; params is the condition for nailing the page context, and the shallow comparison changes will return to page 1 for rechecking. request/params can all be inlined and no requests will be repeated.

Department (fixed query parameters)
Default is in descending order of monthly salary
No data
0 items
tsx
<ProTable
  title="Default is in descending order of monthly salary"
  columns={columns}
  defaultSorting={[{ id: "salary", desc: true }]}
  params={{ dept }}
  request={async (p) => {
    const { rows, total } = await api.list({
      page: p.page,
      pageSize: p.pageSize,
      sort: p.sort,
      ...p.filters,
      ...p.params,
    });
    return { data: rows, total };
  }}
/>

cursor Paging

paginationMode="cursor", request returns { data, nextCursor, hasMore }, with the previous/next page at the bottom.

cursor Paging (Previous Page/Next Page · None total)
No data
tsx
<ProTable
  title="Log"
  columns={columns}
  request={request}
  paginationMode="cursor"
  defaultPageSize={8}
  pageSizeOptions={[8, 16, 32]}
/>

Display mode (controlled paging)

When managing data/paging, just pass data + pagination + search callback.

Employee List
Employees 011R&D DepartmentWorking2024-01-15¥8,000
Employees 022Marketing DepartmentResignation2024-02-15¥9,500
Employees 033Finance DepartmentTo be hired2024-03-15¥11,000
Employees 044Human Resources DepartmentWorking2024-04-15¥12,500
Employees 055R&D DepartmentResignation2024-05-15¥14,000
Employees 066Marketing DepartmentTo be hired2024-06-15¥15,500
Employees 077Finance DepartmentWorking2024-07-15¥17,000
Employees 088Human Resources DepartmentResignation2024-08-15¥18,500
47 items
…More pages
tsx
<ProTable
  title="Employee List"
  columns={columns}
  data={pageData}
  enableRowSelection
  onReload={reload}
  toolbarActions={<Button size="sm">+ New employee</Button>}
  search={{ fields: searchFields, onSearch, onReset }}
  pagination={{ page, pageSize, total, onPageChange: setPage }}
/>

Simplified table

Compact density + full screen button off + no query area.

Compact table (no query area)
Employees 011R&D DepartmentWorking
Employees 022Marketing DepartmentResignation
Employees 033Finance DepartmentTo be hired
Employees 044Human Resources DepartmentWorking
Employees 055R&D DepartmentResignation
tsx
<ProTable
  title="Compact Table"
  columns={columns.slice(0, 4)}
  data={rows}
  density="compact"
  toolbar={{ fullscreen: false }}
/>

When to use

Use ProTable for a complete enterprise list page: search form, toolbar, table, and pagination in one component. Prefer it for server pagination, sorting, and filtering. Table is the lower-level table skin; ProTable's managed mode also owns the request lifecycle.

Import

ts
import { ProTable } from "@hulianui/ui"

Props

Inherits Omit<TableProps<TData>, "data">, including columns, sorting, selection, density, row identity, and row classes, and adds:

Enable virtual for large result sets. It is inherited from Table even though it is not repeated in the table below: tsx <ProTable columns={columns} request={fetchRows} virtual={{ enabled: true, height: 480 }} /> See Table virtual for parameters and constraints. It requires @tanstack/react-virtual and is not recommended with trees, expanded detail panels, or row drag-and-drop.
NameTypeDefaultDescription
dataTData[]-Required in display mode; ignored when request enables managed mode.
request(params: ProTableRequestParams) => Promise<ProTableRequestResult<TData>>-Enables managed data, paging, sorting, filters, loading, and selection. Held in a ref, so function identity is not a request dependency.
paramsRecord<string, unknown>-Fixed managed-mode parameters. Shallow changes reset to page one and re-request; values remain separate from filters.
paginationMode"page" | "cursor""page"Page mode returns {data,total}; cursor mode receives a cursor and returns {data,nextCursor,hasMore}.
defaultPageSizenumber10Initial managed page size.
defaultSortingSortingState[]Initial managed sorting, read only on first mount and sent with the first request.
pageSizeOptionsnumber[]-Renders a page-size selector when supplied.
paginationProTablePagination-Display-mode footer pagination: {page,pageSize,total,onPageChange,showFirstLast?,onPageSizeChange?}.
searchOmit<SearchFormProps,"onSearch"> & { onSearch? }-Integrated SearchForm; onSearch is optional in managed mode; defaults to variant="embedded" (flat subtle panel without double shadow) and accepts variant: "card" to opt back into an elevated card.
filterChipsboolean | ProTableFilterChipsConfigfalseBuilt-in active filter summary bar (FilterChipGroup): renders removable chips from search.fields labels and options whenever filters are active, supporting single-item removal and clear-all reset. Accepts a config object with when ("always" | "collapsed"), size, formatValue, clearAllLabel, and className.
toolbarboolean | ProTableToolbarFeaturestrueTrue enables all tools, false hides the toolbar, or configure reload, density, column settings, and fullscreen individually.
loadingboolean-Display-mode loading state (managed mode drives its own via request and ignores this). It spins the refresh icon and splits into two cases: with rows on screen it lays a translucent overlay over them (the previous batch stays readable), and with no rows at all the inner Table renders skeleton rows and no overlay — an overlay with "No data" showing through says "loading" and "nothing here" at the same time.
loadingRowsnumberPage sizeSkeleton row count for the first load, forwarded to Table. Defaults to the current pagination.pageSize, falling back to the managed page size when no pagination is rendered; pass a value to override it.
actionRefRef<ProTableActions>-Exposes reload(), clearSelection(), getFilters(), setFilters(), removeFilter(name), and resetFilters().
columnVisibilityRecord<string, boolean>-Controlled column visibility, mapping column id to visibility, where a missing key means visible. It follows the rowSelection and sorting contract: supplying it takes control and requires onColumnVisibilityChange, omitting it keeps internal state. Column ids come from ColumnDef.id, falling back to accessorKey. Columns carrying meta.lockVisible stay visible, so writing false for them has no effect.
rootClassNamestring-Outer container class, distinct from the Table className. Root element exposes data-slot="pro-table" and reads --hl-pro-table-pad / --hl-pro-table-gap (both default to 1rem) for global theme spacing overrides.

Events

Inherited Table events include sorting, selection, expansion, and column-filter changes. ProTable adds:

EventTypeDescription
onReload() => voidCalled from the toolbar reload control.
onRequestError(error: unknown) => voidManaged request failure handler; defaults to console.error, resets loading, and preserves previous data.
onColumnVisibilityChange(next: Record<string, boolean>) => voidColumn-visibility change. It reports the complete next map, not a patch, so it can be written straight to local storage or PATCHed back to the server.

Slots

SlotTypeDescription
titleReactNodeCard title on the left side of the toolbar.
toolbarActionsReactNodeCustom actions before the built-in toolbar controls.
batchActions(ctx: ProTableBatchCtx) => ReactNodeRenders batch operations when selection is enabled and rows are selected.

Usage notes

  • Memoize columns (same root cause as Table): TanStack's flexRender renders a function cell as a component type, so a changed identity unmounts and remounts the cell. With an input inside, a controlled field loses focus on every keystroke and an onBlur submit fires on the remount blur, committing a half-typed value. Never put a per-keystroke value in the useMemo dependencies, and prefer uncontrolled inputs for inline editing.
  • In managed mode, data, pagination, and loading are ignored. Managed mode enables manualSorting by default (so request owns server-side sorting without client-side re-sorting of the current page; pass manualSorting={false} to opt back into client sorting), and changing sorting resets both page and cursor pagination back to page one. Cursor mode has no total or random page jump; changing filters, sorting, or page size resets to page one.
  • Supply getRowId in managed mode so selection remains stable across pages. batchActions also requires enabled selection and at least one selected row.
  • Row selection is controlled by whether you pass rowSelection, not by whether the table is managed. Passing it makes selection controlled, so pass onRowSelectionChange too. Without it nothing can be selected and only a dev warning says why. Omit both and the component holds selection internally. Through 0.29.0 managed mode always held selection and silently discarded these two props: the table looked completely normal, checkboxes toggled and the header box went indeterminate, yet the consumer state stayed {} until submit produced an empty array (#202). In controlled mode clearSelection goes through onRowSelectionChange too (the batch bar's "clear" link, the one handed to batchActions, and actionRef.clearSelection() are the same function) - through 0.65.0 it was hard-wired to the internal state, so clicking it in controlled mode did nothing at all (#356).
  • Column visibility follows the same controlled contract as selection: supplying columnVisibility means you own it and must also supply onColumnVisibilityChange, otherwise the column-setting popover does nothing and only warns in development. Without it the preference lives in internal state only, so the toolbar works but a refresh throws it away, and "the same operator switches machines and keeps their columns" cannot be written at all from outside the component. The map means missing equals visible, so persistence only has to record the columns that were switched off.
  • Mark identity and action columns with meta.lockVisible. A blanket on/off list cannot express "these two may not be switched off", and a row without its identity column or its action column has neither a name nor an exit. Locked columns are checked and disabled in the toolbar, and a controlled false does not apply to them either, otherwise one stale persisted preference could close the exit with no way to reopen it from the UI.
  • The guard against hiding the last visible column (which would leave an empty header) is still in place; in controlled mode it shows up as the change handler simply not firing.
  • Request rejection falls back to console.error; use onRequestError for a production toast or report.
  • request is held in a ref. Inline functions do not loop, but replacing only the function does not reload; change params or call actionRef.reload().
  • defaultSorting is an uncontrolled initial value. Later changes do not overwrite user sorting; remount with a key or use controlled sorting.
  • params is compared only one level deep. Flat inline objects are safe; keep nested values referentially stable or flatten them.
  • params stays separate from filters, so fixed constraints cannot be reset or overwritten by the search form. Merge them explicitly inside request.
  • Any params content change resets page mode to page one and cursor mode to the start.

Related

Table · Book3D · PricingTable · JsonViewer · EditableTable · List

PreviousBook3DData DisplayNextPricingTable

On this page

  • Usage
  • Documentation
    • When to use
    • Import
    • Props
    • Events
    • Slots
    • Usage notes
    • Related