# file-manager-template

> File manager with templated navigation pane, card-style large icons and custom details columns.

**Framework:** react  **Component:** FileManager  **Variant:** template

## Get this item

**If you are an agent, fetch the JSON.** Source is inlined, so one request is enough and no tooling is required:

```
GET https://ai.syncfusion.com/r/react/js/file-manager-template.json
```

**Install Package(s)**

```bash
npm install @syncfusion/ej2-react-filemanager @syncfusion/ej2-react-splitbuttons
```

**Notes**

- Syncfusion release: 2026 Volume 3 (v35.1.37)
- The Syncfusion package is licensed. The composition in this file is source you own and edit. See https://ai.syncfusion.com/licensing.md

## Source files

### src/components/file-manager-template/FileManager.jsx

```jsx
import { useRef } from 'react';
import { createRoot as reactCreateRoot } from 'react-dom/client';
import { FileManagerComponent, Inject, NavigationPane, DetailsView, Toolbar } from '@syncfusion/ej2-react-filemanager';
import { DropDownButtonComponent } from '@syncfusion/ej2-react-splitbuttons';
/**
 * File Manager template sample
 */
const SAMPLE_CSS = `
.e-filemanager.e-fm-template-sample .e-list-icon {
    height: 20px !important;
    margin: 0 !important;
    width: 20px !important;
}
.e-dropdown-btn.filemanager-dropdown-button {
    border: none;
    margin-right: -6px;
    box-shadow: none;
    background: transparent;
}
.e-dropdown-btn.filemanager-dropdown-button:hover, .e-dropdown-btn.filemanager-dropdown-button.e-btn:hover {
    background: #d4d4d4;
}
.fluent2-dark .e-dropdown-btn.filemanager-dropdown-button:hover, .fluent2-dark .e-dropdown-btn.filemanager-dropdown-button.e-btn:hover,
.fluent-dark .e-dropdown-btn.filemanager-dropdown-button:hover, .fluent-dark .e-dropdown-btn.filemanager-dropdown-button.e-btn:hover,
.material3-dark .e-dropdown-btn.filemanager-dropdown-button:hover, .material3-dark .e-dropdown-btn.filemanager-dropdown-button.e-btn:hover,
.tailwind3-dark .e-dropdown-btn.filemanager-dropdown-button:hover, .tailwind3-dark .e-dropdown-btn.filemanager-dropdown-button.e-btn:hover,
.fluent2-highcontrast .e-dropdown-btn.filemanager-dropdown-button:hover, .fluent2-highcontrast .e-dropdown-btn.filemanager-dropdown-button.e-btn:hover,
.highcontrast .e-dropdown-btn.filemanager-dropdown-button:hover, .highcontrast .e-dropdown-btn.filemanager-dropdown-button.e-btn:hover,
.bootstrap5\\.3-dark .e-dropdown-btn.filemanager-dropdown-button:hover, .bootstrap5\\.3-dark .e-dropdown-btn.filemanager-dropdown-button.e-btn:hover {
    background: #3d3d3d;
}
.bootstrap5\\.3 .e-dropdown-btn.filemanager-dropdown-button {
    color: #242424;
}
.e-filemanager.e-fm-template-sample .e-grid .e-gridheader .e-fe-grid-icon + .e-rowcell, .e-filemanager .e-grid .e-gridheader .e-fe-grid-icon + .e-headercell, .e-filemanager .e-grid .e-gridcontent .e-fe-grid-icon + .e-rowcell, .e-filemanager .e-grid .e-gridcontent .e-fe-grid-icon + .e-headercell {
    padding-left: 6px;
}
.e-fm-template-sample .e-nav-pane-node .e-icons {
    font-size: larger;
}
.e-fm-template-sample .custom-icon-card {
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 10px;
    height: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
}
.e-fm-template-sample .file-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin-bottom: 10px;
}
.e-fm-template-sample .left-info {
    display: flex;
    align-items: center;
    gap: 8px;
    overflow: hidden;
    flex-shrink: 1;
    flex-grow: 1;
}
.e-fm-template-sample .file-name {
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 160px;
}
.e-fm-template-sample .file-formattedDate {
    font-size: 12px;
    margin-top: 8px;
    text-align: center;
    font-weight: 600;
}
.e-filemanager.e-fm-template-sample.e-fe-mobile .e-large-icons .e-list-parent .e-list-item {
    height: 185px;
    width: 100px;
    margin: 8px 4px;
}
.e-filemanager.e-fm-template-sample.e-fe-mobile .e-large-icons .e-list-parent .e-list-item .file-icon {
    width: 150px;
    height: 90px;
}
.e-filemanager.e-fm-template-sample.e-fe-mobile .e-large-icons .e-list-parent .e-list-item .file-name {
    max-width: 100px;
}
.e-filemanager.e-fm-template-sample .e-large-icons .e-list-item {
    height: 230px;
    width: 200px;
}
#template_filemanager.e-fm-template-sample .e-layout-content {
    overflow: hidden;
}
.e-filemanager.e-fm-template-sample .e-large-icons .e-list-parent .e-list-item .file-icon {
    width: 190px;
    height: 150px;
    background-repeat: no-repeat;
    background-position: center center;
    background-size: contain;
    margin-bottom: 10px;
}

.tailwind3 .e-filemanager.e-fm-template-sample .e-treeview .e-text-content,
.tailwind3-dark .e-filemanager.e-fm-template-sample .e-treeview .e-text-content {
    top: 0;
}
.e-filemanager.e-fm-template-sample .e-treeview .e-list-text {
    display: inline-flex;
}

/* Background images */
.background-folder { background-image: url('/file-manager/template/folders.svg'); }
.background-png { background-image: url('/file-manager/template/image-png.svg'); }
.background-pptx { background-image: url('/file-manager/template/pptx.png'); }
.background-jpg { background-image: url('/file-manager/template/image-jpg.svg'); }
.background-doc { background-image: url('/file-manager/template/docx.png'); }
.background-pdf { background-image: url('/file-manager/template/pdfphoto.png'); }
.background-txt { background-image: url('/file-manager/template/text.png'); }
.background-video { background-image: url('/file-manager/template/video.png'); }
.background-audio { background-image: url('/file-manager/template/music.png'); }
.background-xlsx { background-image: url('/file-manager/template/xlsx.png'); }
.background-zip { background-image: url('/file-manager/template/zip.svg'); }
/* People */
.background-Adam { background-image: url('/file-manager/template/Adam.png'); }
.background-Andrew { background-image: url('/file-manager/template/Andrew.png'); }
.background-Ellie { background-image: url('/file-manager/template/Ellie.png'); }
.background-Jameson { background-image: url('/file-manager/template/Jameson.png'); }
.background-John { background-image: url('/file-manager/template/John.png'); }
.background-Josie { background-image: url('/file-manager/template/Josie.png'); }

/* Food */
.background-Applepie { background-image: url('/file-manager/template/Apple pie.png'); }
.background-Bread { background-image: url('/file-manager/template/Bread.png'); }
.background-Doughnut { background-image: url('/file-manager/template/Doughnut.png'); }
.background-Nuggets { background-image: url('/file-manager/template/Nuggets.png'); }
.background-Sugarcookie { background-image: url('/file-manager/template/Sugar cookie.png'); }

/* Nature */
.background-bird { background-image: url('/file-manager/template/bird.jpg'); }
.background-sea { background-image: url('/file-manager/template/sea.jpg'); }
.background-seaview { background-image: url('/file-manager/template/seaview.jpg'); }
.background-snow { background-image: url('/file-manager/template/snow.jpg'); }
.background-snowfall { background-image: url('/file-manager/template/snowfall.jpg'); } `;
const hostUrl = 'https://physical-service.syncfusion.com/';
const actionItems = [
    { text: 'Open', iconCss: 'e-icons e-folder-open' },
    { text: 'Download', iconCss: 'e-icons e-download' },
    { text: 'Refresh', iconCss: 'e-icons e-refresh' },
    { text: 'Delete', iconCss: 'e-icons e-trash' },
];
const Template = () => {
    const fmRef = useRef(null);
    const formatSize = (bytes) => {
        if (!bytes)
            return '0 B';
        const sizes = ['B', 'KB', 'MB', 'GB', 'TB'];
        let i = 0;
        let value = bytes;
        while (value >= 1024 && i < sizes.length - 1) {
            value /= 1024;
            i++;
        }
        return `${value.toFixed(1)} ${sizes[i]}`;
    };
    const getBackgroundCss = (item) => {
        const NamedFileBackgrounds = {
            'Adam.png': 'background-Adam',
            'Andrew.png': 'background-Andrew',
            'Ellie.png': 'background-Ellie',
            'Jameson.png': 'background-Jameson',
            'John.png': 'background-John',
            'Josie.png': 'background-Josie',
            'Apple pie.png': 'background-Applepie',
            'Bread.png': 'background-Bread',
            'Doughnut.png': 'background-Doughnut',
            'Nuggets.png': 'background-Nuggets',
            'Sugar cookie.png': 'background-Sugarcookie',
            'bird.jpg': 'background-bird',
            'sea.jpg': 'background-sea',
            'seaview.jpg': 'background-seaview',
            'snow.jpg': 'background-snow',
            'snowfall.jpg': 'background-snowfall'
        };
        const ExtensionBackgrounds = {
            jpg: 'background-jpg',
            jpeg: 'background-jpg',
            png: 'background-png',
            pptx: 'background-pptx',
            pdf: 'background-pdf',
            mp4: 'background-video',
            mp3: 'background-audio',
            docx: 'background-doc',
            txt: 'background-txt',
            xlsx: 'background-xlsx',
            zip: 'background-zip',
        };
        if (!item.isFile)
            return 'file-icon background-folder';
        if (NamedFileBackgrounds[item.name])
            return `file-icon ${NamedFileBackgrounds[item.name]}`;
        const ext = (item.name.split('.').pop() || '').toLowerCase();
        return `file-icon ${ExtensionBackgrounds[ext] || 'background-default'}`;
    };
    const getIconsForFolders = (item) => {
        const iconMap = {
            Files: 'e-folder',
            Documents: 'e-file-document',
            Downloads: 'e-download',
            Pictures: 'e-thumbnail',
            Music: 'e-file-format',
            Videos: 'e-video',
            Employees: 'e-export-png',
            Food: 'e-export-png',
            Nature: 'e-export-png'
        };
        return iconMap[item.name] || 'e-folder';
    };
    const getFileIconCssClass = (item) => {
        if (!item.isFile)
            return '';
        const extensionMap = {
            jpg: 'image',
            jpeg: 'image',
            png: 'image',
            gif: 'image',
            mp3: 'music',
            wav: 'music',
            mp4: 'video',
            avi: 'video',
            doc: 'doc',
            docx: 'docx',
            ppt: 'pptx',
            pptx: 'pptx',
            xls: 'xlsx',
            xlsx: 'xlsx',
            txt: 'txt',
            js: 'js',
            css: 'css',
            html: 'html',
            exe: 'exe',
            msi: 'msi',
            php: 'php',
            xml: 'xml',
            zip: 'zip',
            rar: 'rar',
            pdf: 'pdf'
        };
        const extension = (item.name.split('.').pop() || '').toLowerCase();
        const iconType = extensionMap[extension] || 'unknown';
        return `e-list-icon e-fe-${iconType}`;
    };
    const onActionSelect = (action, item) => {
        if (!fmRef.current)
            return;
        switch (action) {
            case 'Open':
                fmRef.current.openFile(item.name);
                break;
            case 'Download':
                fmRef.current.downloadFiles([item.name]);
                break;
            case 'Refresh':
                fmRef.current.refreshFiles();
                break;
            case 'Delete':
                fmRef.current.deleteFiles([item.name]);
                break;
            default:
                break;
        }
    };
    // Render DropDownButtonComponent (React) into each action host
    const renderDDBIntoHost = (hostEl) => {
        const fileName = hostEl.getAttribute('data-name') || '';
        const isFile = (hostEl.getAttribute('data-isfile') || 'false') === 'true';
        const items = isFile ? actionItems.filter(i => i.text !== 'Open') : actionItems;
        const onSelect = (args) => {
            const action = args?.item?.text || '';
            onActionSelect(action, { name: fileName, isFile });
        };
        if (!hostEl.hasAttribute('data-ddb-initialized')) {
            const root = reactCreateRoot(hostEl);
            root.render(<DropDownButtonComponent items={items} cssClass="e-caret-hide filemanager-dropdown-button" iconCss="e-icons e-more-vertical-1" select={onSelect}/>);
            hostEl.setAttribute('data-ddb-initialized', 'true');
        }
    };
    const menuOpen = (args) => {
        args.cancel = true;
    };
    const fileLoad = (args) => {
        const validModules = ['DetailsView', 'LargeIconsView'];
        if (validModules.indexOf(args.module) !== -1) {
            setTimeout(() => {
                const actionBtn = args.element.querySelector('.action-ddb');
                if (actionBtn && !actionBtn.hasAttribute('data-ddb-initialized')) {
                    renderDDBIntoHost(actionBtn);
                }
            }, 10);
        }
    };
    const detailsViewSettings = {
        columns: [
            {
                field: 'name',
                headerText: 'Name',
                template: (item) => (<div>{item.name}</div>)
            },
            {
                field: 'size',
                headerText: 'Size',
                template: (item) => (<div>{item.isFile ? formatSize(item.size) : '-'}</div>)
            },
            {
                field: '_fm_modified',
                headerText: 'DateModified',
                format: 'MM/dd/yyyy hh:mm a'
            },
            {
                headerText: 'Actions',
                template: (item) => (<div className="action-ddb" data-name={item.name} data-isfile={item.isFile}/>)
            }
        ]
    };
    const largeIconsTemplate = (item) => {
        const formattedDate = item.dateCreated
            ? new Date(item.dateCreated).toLocaleDateString('en-US', {
                year: 'numeric',
                month: 'long',
                day: 'numeric',
            })
            : '';
        const iconClass = getFileIconCssClass(item);
        const backgroundClass = getBackgroundCss(item);
        return (<div className="custom-icon-card">
        <div className="file-header">
          <div className="left-info">
            {item.isFile && <div className={iconClass}></div>}
            <div className="file-name" title={item.name}>
              {item.name}
            </div>
          </div>
          <div className="action-ddb" data-name={item.name} data-isfile={item.isFile}></div>
        </div>
        <div className={backgroundClass} title={item.name}></div>
        <div className="file-formattedDate">Created on {formattedDate}</div>
      </div>);
    };
    const navigationPaneTemplate = (item) => {
        const iconClass = getIconsForFolders(item);
        return (<div className="e-nav-pane-node" style={{ display: 'inline-flex', alignItems: 'center' }}>
        <span className={`e-icons ${iconClass}`}></span>
        <span className="folder-name" style={{ marginLeft: 8 }}>{item.name}</span>
      </div>);
    };
    return (<div>
      <div className="control-section">
        <style>{SAMPLE_CSS}</style>
        <div className="sample-container">
          <FileManagerComponent id="template_filemanager" ref={fmRef} ajaxSettings={{
            url: `${hostUrl}api/FileManager/FileOperations`,
            uploadUrl: `${hostUrl}api/FileManager/Upload`,
            downloadUrl: `${hostUrl}api/FileManager/Download`,
            getImageUrl: `${hostUrl}api/FileManager/GetImage`
        }} cssClass="e-fm-template-sample" height="600px" detailsViewSettings={detailsViewSettings} largeIconsTemplate={largeIconsTemplate} navigationPaneTemplate={navigationPaneTemplate} menuOpen={menuOpen} fileLoad={fileLoad}>
            <Inject services={[NavigationPane, DetailsView, Toolbar]}/>
          </FileManagerComponent>
        </div>
      </div>
    </div>);
};
export default Template;

```
