SuperSimpleBlazorDropzone 1.1.0
dotnet add package SuperSimpleBlazorDropzone --version 1.1.0
NuGet\Install-Package SuperSimpleBlazorDropzone -Version 1.1.0
<PackageReference Include="SuperSimpleBlazorDropzone" Version="1.1.0" />
<PackageVersion Include="SuperSimpleBlazorDropzone" Version="1.1.0" />
<PackageReference Include="SuperSimpleBlazorDropzone" />
paket add SuperSimpleBlazorDropzone --version 1.1.0
#r "nuget: SuperSimpleBlazorDropzone, 1.1.0"
#:package SuperSimpleBlazorDropzone@1.1.0
#addin nuget:?package=SuperSimpleBlazorDropzone&version=1.1.0
#tool nuget:?package=SuperSimpleBlazorDropzone&version=1.1.0
Super Simple Blazor Dropzone
Super Simple Blazor Dropzone is a lightweight and easy-to-use file dropzone component for Blazor applications. It allows you to receive files via drag-and-drop or file picker, with minimal configuration and effort.
Features
- Simple and intuitive API
- Lightweight and fast
- Customizable with CSS classes and content
- Supports .NET 8 and .NET 9
- Supports both base64 and binary file transfer
- JavaScript interop for drag-and-drop and file selection
- Supports multiple file uploads
Installation
To install the package, run the following command:
dotnet add package SuperSimpleBlazorDropzone
Usage
Use the SimpleDropzone
component in your Blazor pages or components:
@using SuperSimpleBlazorDropzone
<SimpleDropzone OnBase64FilesReceived="@OnBase64FilesReceived" />
@code {
private Base64FileTransfer? _base64File;
private void OnBase64FilesReceived(IEnumerable<Base64FileTransfer> files)
{
_base64File = files.FirstOrDefault();
}
}
Customizing Content and Output
You can customize the dropzone's appearance, output type, and content. For example, to receive binary data and use custom CSS/content:
<SimpleDropzone
CssClass="custom"
DragActiveCssClass="custom-drag-active"
ContentOutputType="@FileContentOutput.Binary"
OnBinaryFilesReceived="@OnBinaryFilesReceived">
<span>As you can see, this is some customized content for binary files. Please drop here to see it working</span>
</SimpleDropzone>
@code {
private BinaryFileTransfer? _binaryFile;
private void OnBinaryFilesReceived(IEnumerable<BinaryFileTransfer> files)
{
_binaryFile = files.FirstOrDefault();
}
}
Multiple File Uploads
Enable multiple file uploads by setting AllowMultipleFiles="true"
:
<SimpleDropzone AllowMultipleFiles="true" OnBase64FilesReceived="@OnMultipleFilesReceived" />
@code {
private List<Base64FileTransfer> _multipleFiles = new();
private void OnMultipleFilesReceived(IEnumerable<Base64FileTransfer> files)
{
_multipleFiles = files.ToList();
}
}
Example Output Rendering
@if (_binaryFile != null)
{
<div>
<h4>File Name: @_binaryFile.Name</h4>
<h4>File Size: @_binaryFile.Size</h4>
<h4>File Type: @_binaryFile.Type</h4>
<h4>File Extension: @_binaryFile.Extension</h4>
<h4>File Content:</h4>
<pre class="w-100 text-truncate" style="max-width: 100%; max-height: 10rem; overflow: auto;">
@(_binaryFile.Content != null
? BitConverter.ToString(_binaryFile.Content).Replace("-", " ")
: string.Empty)
</pre>
@if (!string.IsNullOrWhiteSpace(_binaryFile.ImgSrc))
{
<img src="@_binaryFile.ImgSrc" alt="Uploaded Image" />
}
</div>
}
Parameters
CssClass
(string
): The CSS class applied to the dropzone container. Default is"file-dropper"
.DragActiveCssClass
(string
): The CSS class applied when a file is being dragged over the dropzone. Default is"drag-active"
.ContentOutputType
(FileContentOutput
): Determines the format of the file content received (Base64
orBinary
). Default isBase64
.DropperId
(string
): The unique ID for the dropzone element. Defaults to a new GUID.ChildContent
(RenderFragment?
): Custom content to render inside the dropzone. If not provided, a default message is shown.OnBase64FilesReceived
(EventCallback<IEnumerable<Base64FileTransfer>>
): Callback invoked when one or more files are received as base64 data.OnBinaryFilesReceived
(EventCallback<IEnumerable<BinaryFileTransfer>>
): Callback invoked when one or more files are received as binary data.AllowMultipleFiles
(bool
): Iftrue
, allows multiple file selection and drag-and-drop. Default isfalse
.
Styling
You can customize the dropzone with your own CSS classes. Example:
.custom {
border: 3px dashed #ff6f61;
border-radius: 16px;
padding: 40px;
text-align: center;
cursor: pointer;
background: linear-gradient(135deg, #f9d423 0%, #ff4e50 100%);
color: #fff;
font-weight: bold;
font-size: 1.2rem;
}
.custom-drag-active {
border-color: #43cea2;
background: linear-gradient(135deg, #43cea2 0%, #185a9d 100%);
color: #fff;
animation: dragPulse 1s infinite alternate;
}
@keyframes dragPulse {
from { box-shadow: 0 0 24px 4px #43cea2; }
to { box-shadow: 0 0 48px 8px #43cea2; }
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- Microsoft.AspNetCore.Components.Web (>= 8.0.19)
-
net9.0
- Microsoft.AspNetCore.Components.Web (>= 9.0.8)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.