AdaptTable for shadcn

Saved views in shadcn

A view is everything the table can put in a URL — search, sort, filters, grouping, the column layout, density and the pivot — saved under a name.

Readers pick one from the views menu; the panel beside the table renames, reorders, sets the default and deletes. A view someone else shared arrives read-only and says so on the row.

Both are semantic markup wearing the shadcn class preset: the surface is bg-card, the rows highlight on bg-muted, and the save button is bg-primary — the tokens your own components already read.

The panel and the toolbar menu share one set of class keys, so both read as the same surface: bg-card over border-border, rows highlighting on bg-muted, and the save action in bg-primary.

The code

import {
  DataTable,
  SavedViewsPanel,
  useSavedViews,
} from "@adapttable/shadcn";

export function People({ rows, columns }) {
  const views = useSavedViews({
    storageKey: "people-views",
    urlKey: "v",
  });
  return (
    <>
      <SavedViewsPanel
        views={views.views}
        onApply={views.apply}
        onRename={views.rename}
        onMove={views.move}
        onSetDefault={views.setDefault}
        onRemove={views.remove}
      />
      <DataTable
        data={rows}
        columns={columns}
        rowKey={(row) => row.id}
        urlKey="v"
        savedViews={{ storageKey: "people-views" }}
      />
    </>
  );
}

Install

pnpm add @adapttable/shadcn @adapttable/core

The same feature in the other kits

More shadcn features

Reference: saved-views, url-state. More of this kit: AdaptTable for shadcn, or the live demo.