AdaptTable for Chakra

Saved views in Chakra

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

The panel is a bordered Box rather than a Card — Chakra's Card carries padding this list does not want — with a ghost Button per name, an xs Input for renaming, and Badges for the default and read-only markers.

The code

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

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

The same feature in the other kits

More Chakra features

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