Components
The shadcn registry items: an export menu, a pivot table and a pivot designer. Their source is in your project after npx shadcn add.
ExportMenu
componentA dropdown button that exports the table to Excel, PDF or CSV and saves the
file. While an export runs the button reads "Exporting..." and further picks
are ignored. A "Selected rows only" checkbox appears when the table has
selected rows, or as allowSelectedOnly says.
Source in your project: components/export-menu.tsx
ExportMenu(
{ table, fileName, pdfTitle, formats, rowStyle, allowSelectedOnly, onError, label, className, theme, pdfOptions, xlsxOptions, }: ExportMenuProps,
) => anyParameters
| Name | Type | Description |
|---|---|---|
__0 | ExportMenuProps | See ExportMenuProps. |
Returns
any
ExportMenuProps
typeProps of ExportMenu.
Source in your project: components/export-menu.tsx
Properties
| Name | Type | Description |
|---|---|---|
table | TableLike | A TanStack table (v8 or v9), or pivot.table from createPivot. |
fileNameoptional | string | File name without extension. |
pdfTitleoptional | string | Title printed at the top of the PDF. |
formatsoptional | Format[] | Which formats to offer. Default all three. |
rowStyleoptional | ((original: unknown) => CellStyle | undefined) | Style whole rows, e.g. pivotRowStyle for pivots. |
allowSelectedOnlyoptional | boolean | Offer "Selected rows only". Default: when the table has a selection. |
onErroroptional | ((error: unknown) => void) | Called when an export fails. Default: console.error. |
labeloptional | string | Button text. Default 'Export'. |
classNameoptional | string | Classes added to the trigger button. |
themeoptional | "page" | "none" | Colors for the Excel and PDF files. "page" (default) reads your shadcn/ui theme, so the files look like the table; "none" keeps rowpine's defaults. |
pdfOptionsoptional | PdfTableExportOptions | More PDF options, such as pageSize or kpis. They win over the theme colors. |
xlsxOptionsoptional | XlsxExportOptions | More Excel options, such as sheetName. They win over the theme colors. |
PivotTable
componentA pivot as a shadcn Table: header groups span their columns, rows with children get an expand and collapse button, and empty value cells show '-'.
Source in your project: components/pivot-table.tsx
PivotTable(
{ pivot, collapsed, onCollapsedChange, defaultCollapsed, className }: PivotTableProps,
) => anyParameters
| Name | Type | Description |
|---|---|---|
__0 | PivotTableProps | See PivotTableProps. |
Returns
any
PivotTableProps
typeProps of PivotTable.
Source in your project: components/pivot-table.tsx
Properties
| Name | Type | Description |
|---|---|---|
pivot | PivotModel | The pivot to show, from usePivot or createPivot. |
collapsedoptional | any | Collapsed group ids, to control expansion from outside. |
onCollapsedChangeoptional | ((collapsed: Set<string>) => void) | Called with the new set of collapsed ids when a row is expanded or
collapsed. When given, the table does not keep its own state, so pass
collapsed with it. |
defaultCollapsedoptional | boolean | Start with every group collapsed when uncontrolled. Default false. |
classNameoptional | string | Classes added to the bordered wrapper. |
usePivot
hookPivot data with config; recomputes only when either changes.
Source in your project: components/pivot-table.tsx
usePivot<TData>(
data: ReadonlyArray<TData>,
config: PivotConfig<TData>,
options?: ToColumnsOptions,
) => PivotModelParameters
| Name | Type | Description |
|---|---|---|
data | readonly TData[] | Source rows. A new array on each render rebuilds the pivot. |
config | PivotConfig<TData> | The pivot config. Keep the same object between renders (a constant or useMemo); a new one rebuilds the pivot. |
optionsoptional | ToColumnsOptions | Settings for every value column, such as an Excel number format. Same rule as config. |
Returns
PivotModel
PivotDesigner
componentAn Excel-style pivot designer: field list, four wells, and the pivot it builds.
Uncontrolled, it starts from defaultLayoutFor.
Source in your project: components/pivot-designer.tsx
PivotDesigner<TData>(
{ data, fields, layout: controlled, onLayoutChange, presets, aggregators, pivotOptions, actions, onPivotChange, className, }: PivotDesignerProps<TData>,
) => anyParameters
| Name | Type | Description |
|---|---|---|
__0 | PivotDesignerProps<TData> | See PivotDesignerProps. |
Returns
any
PivotDesignerProps<TData>
typeProps of PivotDesigner.
Source in your project: components/pivot-designer.tsx
Properties
| Name | Type | Description |
|---|---|---|
data | readonly TData[] | Source rows. The filter value lists are read from all of them. |
fields | readonly PivotField<TData>[] | The fields offered in the field list. kind decides which wells take each one. |
layoutoptional | PivotLayout | The layout, to control it. Store it as JSON to save a user's view. |
onLayoutChangeoptional | ((layout: PivotLayout) => void) | Called with each new layout. Without layout the designer also keeps the layout itself. |
presetsoptional | readonly PivotPreset[] | Saved layouts offered in the Presets menu. |
aggregatorsoptional | readonly PivotAggregatorId[] | Aggregations offered on value chips. Default all. |
pivotOptionsoptional | ToColumnsOptions | Column options for the pivot, e.g. an Excel number format. |
actionsoptional | ((pivot: PivotModel) => React.ReactNode) | Extra toolbar content, given the current pivot (e.g. an ExportMenu). |
onPivotChangeoptional | ((pivot: PivotModel | null) => void) | Called with each new pivot. |
classNameoptional | string | Classes added to the outer container. |