File Input

DFileInput styles the browser's file picker with daisyUI's file-input. It wraps Blazor's framework InputFile, so OnChange receives InputFileChangeEventArgs without the library shipping any JavaScript of its own.

Pick a file— Reading selection requires interactive rendering; static SSR just renders the control
<DFileInput Color="DaisyColor.Primary" OnChange="OnSingleAsync" />
@if (_single is not null)
{
    <div class="alert alert-info py-2 text-sm">
        <div>
            <strong>@_single.Name</strong>
            &mdash; @FormatSize(_single.Size), @_single.ContentType
        </div>
    </div>
}
 
@code {
    private Microsoft.AspNetCore.Components.Forms.IBrowserFile? _single;
 
    private Task OnSingleAsync(Microsoft.AspNetCore.Components.Forms.InputFileChangeEventArgs e)
    {
        _single = e.File;
        return Task.CompletedTask;
    }
 
    private static string FormatSize(long bytes) => bytes switch
    {
        < 1024 => $"{bytes} B",
        < 1024 * 1024 => $"{bytes / 1024.0:0.#} KB",
        _ => $"{bytes / (1024.0 * 1024.0):0.#} MB",
    };
}
Multiple with accept filter— Images only, up to you how many
<DFileInput Multiple="true" Accept="image/*" OnChange="OnManyAsync" />
@if (_many.Count > 0)
{
    <div class="flex flex-wrap gap-2">
        @foreach (var f in _many)
        {
            <span class="badge badge-accent badge-outline">@f.Name (@FormatSize(f.Size))</span>
        }
    </div>
}
 
@code {
    private readonly List<Microsoft.AspNetCore.Components.Forms.IBrowserFile> _many = [];
 
    private Task OnManyAsync(Microsoft.AspNetCore.Components.Forms.InputFileChangeEventArgs e)
    {
        _many.Clear();
        _many.AddRange(e.GetMultipleFiles(10));
        return Task.CompletedTask;
    }
}
Sizes, colors and disabled
<DFileInput Size="DaisySize.Small" />
<DFileInput Size="DaisySize.Large" Color="DaisyColor.Accent" />
<DFileInput Disabled="true" />

API

DFileInput

Parameters

Name Type Default Binding Description
Accept string — — Native accept filter (e.g. image/*,.pdf ).
Multiple bool False — Allow selecting multiple files.
Disabled bool False — Disables the control.
Color DaisyColor Default — daisyUI color (file-input-primary, ...).
DefaultPrimarySecondaryAccentInfoSuccessWarningErrorGhostNeutral
Size DaisySize Medium — Sizes the control (file-input-xs ... file-input-lg).
ExtraSmallSmallMediumLargeExtraLarge
OnChange EventCallback<InputFileChangeEventArgs> — — Raised when the user picks files (Blazor's InputFileChangeEventArgs ). Reading file content requires interactive rendering.
Class string — — Additional CSS classes appended to the component's computed daisyUI classes.
Style string — — Inline styles applied to the root element.
Connection lost — reconnecting…
Connection failed.
The server has stopped.