AdaptTable for Base UI

Saved views in Base UI

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 Base UI components: the menu, the panel, the rename box and every control on it come from @base-ui/react, so a saved view looks like the rest of your app.

The controls are Base UI's Button and Input, and the panel re-declares the adapter's token class on itself — mounted beside the table it sits outside the table's scope, and every token in it would otherwise resolve to nothing.

The code

import {
  DataTable,
  SavedViewsPanel,
  useSavedViews,
} from "@adapttable/base-ui";

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/base-ui @adapttable/core @base-ui/react

The same feature in the other kits

More Base UI features

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