BulkExportButton

Exports only the currently selected records using dataProvider.getList(). To be used in a ListContext (e.g., inside a <DataTable>).

Installation

pnpm dlx shadcn@latest add @shadmin/bulk-export-button

Usage

<BulkExportButton> is one fo the default bulk action buttons of <DataTable>, so you will need to use it only when you want to customize these bulk actions:

import { DataTable, BulkExportButton } from "@/components/admin";
 
const BulkActions = () => (
  <>
    <BulkExportButton />
    {/* other bulk action buttons */}
  </>
);
 
<DataTable bulkActionsButtons={<BulkActions />}>
  {/* table content */}
</DataTable>;

Props

PropRequiredTypeDefaultDescription
classNameOptionalstring-Extra CSS classes
exporterOptional(data: any[]) => void-Custom exporter function, used to select or augment the exported data
iconOptionalReactNodeDownload iconCustom icon element
labelOptionalstringra.action.exporti18n key
metaOptionalobject-Custom meta to pass to dataProvider.getList()
resourceOptionalstringinferredResource name (rarely needed)

Additional props are passed to the underlying shadcn/ui <Button> component.

icon

Replaces the default <Download /> shown alongside the label. Pass any React node — typically another lucide-react icon.

import { FileDown } from "lucide-react";
 
<BulkExportButton icon={<FileDown />} />;

label

By default, the label is the translation of the ra.action.export key, which reads "Export".

You can customize the label for a specific resource by adding a resources.{resource}.action.export key to your translation messages. It receives %{name} (the singular resource name):

const messages = {
  resources: {
    posts: {
      action: {
        export: "Download %{name}",
      },
    },
  },
};

You can also pass a custom string or translation key directly via the label prop:

<BulkExportButton label="Export selected" />
<BulkExportButton label="resources.posts.action.export" />

See the <List exporter> documentation for details on the exporter function.