Skip to main content
twblazor
Home
  • Get started
  • Tailwind with Blazor
  • Why twblazor?
  • Theme
  • Class Merge
    • Configuring localization
    • RTL Provider
  • Breadcrumb
  • Card
  • Carousel
  • Collapse
  • Context Menu
  • Drawer
  • Footer
  • Menu
  • Navbar
  • On This Page
  • Separator
  • Sidebar
  • Stepper
  • Tabs
  • Tree List
  • Container
  • Flex
  • Grid
  • Text
  • Link
  • Button
  • Form
    • AutocompleteNew
    • Checkbox
    • Color Picker
    • Date Picker
    • Date Range Picker
    • Datetime Picker
    • Datetime Range Picker
    • File Upload
    • Input GroupNew
    • NumericNew
    • Masked InputNew
    • Radio Button
    • Range SliderNew
    • RatingNew
    • Select
    • Slider
    • Switch
    • Tag InputNew
    • Text EditorNew
    • Textfield
    • Time Picker
    • Time Range Picker
  • Toggle
  • Toggle Group
  • Alert
  • Avatar
  • Badge
  • Chip
  • Empty
  • Icon
  • Popover
  • Progress
  • Skeleton
  • Spinner
  • Tooltip
  • Data Table
  • SpreadsheetNew
  • Column Filter Editor
  • Pagination
  • Pick List
  • Barcode
  • QR Code
  • Calendar
  • Table
  • Attachment
  • Overview
    • Bar
    • Bullet
    • Column
    • Dot Plot
    • Dumbbell
    • Icon
    • Lollipop
    • Radial Bar
    • Range
    • Word Cloud
    • Area
    • Bump
    • Bump Area
    • Candlestick
    • Gantt
    • Horizon
    • Line
    • Slope
    • Small Multiples
    • Stream Graph
    • Funnel
    • Gauge
    • Marimekko
    • Nightingale
    • Pie
    • Treemap
    • Waffle
    • Waterfall
    • Circular Treemap
    • Convex Treemap
    • Dendrogram
    • Sunburst
    • Barcode
    • Beeswarm
    • Box Plot
    • Density Plot
    • Histogram
    • Radial Histogram
    • Ridgeline
    • Strip Plot
    • Violin Plot
    • Categorical Scatter
    • Contour
    • Hexagonal Binning
    • Quadrant
    • Scatter
    • Heatmap
    • Matrix
    • Parallel Coordinates
    • Radar
    • Arc Diagram
    • Chord Diagram
    • Flowchart
    • Network Diagram
    • Sankey
    • Euler Diagram
    • Venn Diagram
  • Bubble
  • Marker
  • Message
  • Dialog Service
  • Toast Service
API DocumentationAI Agents & Skills
Home Get Started

Forms

TwFileUpload

TwFileUpload is a Blazor file upload component. Bind Files, restrict types with AllowedFileTypes, allow Multiple files and handle OnChange.

Last updated 10 October 2026

Basic file upload

Use Icon, Label, Variant and Color to style the upload button, and Multiple to allow more than one file.
RAZOR
<div class="space-y-4">
    <TwFileUpload Id="basic-file-upload-input" Icon="@Icon.Upload" Label="Upload file" Variant="ButtonVariant.Outlined" Color="Color.Success" />
    <TwFileUpload Id="multiple-file-upload" Icon="@Icon.Files" Label="Upload multiple files" Multiple Variant="ButtonVariant.Filled" Color="Color.Accent" />
    <TwFileUpload Id="basic-file-upload-2" Icon="Icon.Cloud_Upload" Label="Upload a document" Color="Color.Primary" Variant="ButtonVariant.Outlined" />
    <TwFileUpload Id="basic-file-upload-3" Icon="Icon.Airplane_Fill" Disabled Label="Disabled upload input" Variant="ButtonVariant.Filled" Color="Color.Accent" />
</div>

Binding

Bind @bind-Files to access the list of selected files.
Selected files
    RAZOR
    <div class="space-y-4">
        <TwFileUpload Id="binding-upload" Icon="@Icon.Upload" Label="Bind files" Multiple @bind-Files="@boundFiles" Variant="ButtonVariant.Outlined" Color="Color.Primary" />
    
        <div class="mt-2">
            <strong>Selected files</strong>
            <ul>
                @foreach (var f in boundFiles ?? Enumerable.Empty<IBrowserFile>())
                {
                    <li>@f.Name (@(f.Size) bytes)</li>
                }
            </ul>
        </div>
    </div>
    CSHARP
    @code {
        private List<IBrowserFile>? boundFiles = new();
    }

    Accept (allowed file types)

    Use AllowedFileTypes to restrict which file types can be selected, via the accept attribute.
    RAZOR
    <div class="space-y-4">
        <TwFileUpload Id="accept-upload" Icon="@Icon.Upload" Label="Upload images only" AllowedFileTypes="@(new[] { ".png", ".jpg", "image/png", "image/jpeg" })" Variant="ButtonVariant.Filled" Color="Color.Primary" />
    </div>

    Keyboard navigation

    The upload control is a native file input. Each chosen file is listed with its own remove button, and choosing or removing a file is announced.
    Key What it does
    Tab Moves to the upload control, then to each file's remove button.
    Enter or Space On the upload control: opens the system file dialog.
    Enter or Space On a remove button: removes that file. Focus returns to the upload control.

    Theme configuration

    Styling is controlled by TwBlazorTheme.Components (a TwButtonTheme), configured via the AddTwBlazor() options callback described on the Get Started page. Every property is a set of Tailwind classes, so changes are picked up by your own Tailwind build.

    Inherited from TwButton - this component reuses that theme rather than defining its own.

    Property Type Controls
    ButtonRounded Rounded?
    ButtonShadow Shadow?
    DefaultVariant ButtonVariant?
    ButtonUppercase bool
    Uppercase string
    Base string
    Padding string
    DensePadding string
    IconButton string
    Typography string
    IconTypography string
    DisabledCursor string
    ReadonlyCursor string
    DefaultCursor string
    DisabledFilled string
    DisabledOutlined string
    DisabledText string

    Full reference: TwButtonTheme on the API docs.

    On this page

    • Basic file upload
    • Binding
    • Accept (allowed file types)
    • Keyboard navigation
    • Theme configuration
    twblazor

    The Tailwind CSS component library for Blazor. Accessible, themeable and MIT licensed.

    Discord (opens in a new tab) GitHub(opens in a new tab)

    Get started

    • Install guide
    • Theming
    • Class merging
    • Localization

    Guides

    • Tailwind CSS with Blazor
    • Why twblazor?
    • Right to left
    • AI agents and skills

    Resources

    • API documentation (opens in a new tab)
    • llms.txt (opens in a new tab)
    • MIT License (opens in a new tab)

    Community

    • Contributing (opens in a new tab)
    • Code of conduct (opens in a new tab)
    • Report an issue (opens in a new tab)

    twblazor is and always will be free and open source.

    An unhandled error has occurred. Reload