Skip to main content

LibraryAttachments

LibraryAttachments manages a list item's attachments by storing them in a document library (rather than as classic list attachments), linked back to the item through a lookup field. This gives you versioning, metadata, and large-file support that classic attachments lack.

SPFx component

Imported from @spartanfx/react/spfx; reads and writes a SharePoint document library.

When to use

  • Attach files to list items but keep them in a proper document library (versioning, permissions, metadata).
  • Scope attachments to a section of a form via a section field.

Import

import { LibraryAttachments } from '@spartanfx/react';

Basic usage

Point it at the libraryName and the lookupFieldName that links attachments to the parent item.

<LibraryAttachments
libraryName="Project Attachments"
lookupFieldName="ProjectRef"
accept=".pdf,.docx,.png"
allowMultiple
/>

Scope to a section

<LibraryAttachments
libraryName="Project Attachments"
lookupFieldName="ProjectRef"
section="Contracts"
sectionFieldName="AttachmentSection"
/>

Key props

PropTypeDefaultNotes
libraryName (required)stringTarget document library.
lookupFieldName (required)stringLookup field linking attachments to the item.
acceptstringAcceptable file types (e.g. .pdf,.docx).
allowMultiplebooleantrueAllow multiple attachments.
disabledbooleanDisable upload/delete.
section / sectionFieldNamestringScope attachments to a section.

See the full generated reference: LibraryAttachments API ↗.

See also