DocumentManager
DocumentManager renders a file/folder browser with actions (upload, rename, move, duplicate, delete, copy link, custom actions). Like DataTable, it's props-driven UI: you pass items and toggle the actions you want, and a /spfx or /codeapps adapter hook supplies the data and the operations.
When to use
- Present a SharePoint document library (or Dataverse file column) with a familiar file-explorer UX.
- Any folder-based file browser where you control which actions are available.
Import
import { DocumentManager } from '@spartanfx/react';
Standalone (bring your own data)
items is the only required prop; enable the actions you want.
<DocumentManager
items={documents}
currentPath="/Shared Documents/Projects"
enableUpload
enableRename
enableDelete
allowedFileTypes={['pdf', 'docx', 'xlsx']}
/>
With the SharePoint adapter
The adapter hook returns the items plus operations; wire them into the component:
import { DocumentManager } from '@spartanfx/react';
import { useSharePointDocumentManager } from '@spartanfx/react/spfx';
function LibraryBrowser({ sp }) {
const { items, loading, uploadFiles, deleteItems, refresh } =
useSharePointDocumentManager({
sp,
libraryName: 'Documents',
rootFolderPath: '/sites/mysite/Shared Documents',
});
return (
<DocumentManager
items={items}
enableUpload
enableDelete
onUpload={uploadFiles}
onDelete={deleteItems}
/>
);
}
For Power Apps Code Apps, swap the hook for useCASharePointDocumentManager. See Architecture for how adapters map to targets.
Key props
| Prop | Type | Notes |
|---|---|---|
items (required) | IDocumentItem[] | Documents and folders to display. |
currentPath | string | Folder currently shown. |
enableUpload / enableRename / enableDelete / enableMove / enableDuplicate | boolean | Toggle each action. |
enableMultiSelect | boolean | Allow selecting multiple items. |
allowedFileTypes | string[] | Restrict uploads by extension. |
customActions | ICustomAction[] | Add your own per-item actions. |
See the full generated reference: DocumentManager API ↗ and the adapter hook useSharePointDocumentManager.