BitFileInput component wraps the HTML file input element and allows the user to select file(s) without uploading them. The selected files are returned to the C# context for further processing. It provides several options including single or multiple file selection, drag and drop support, file size validation, and file extension filtering.
Usage
Basic
Select file(s) to see them in the component.
Multiple
Multiple files can be selected.
AutoReset
Automatically resets the BitFileInput state each time before browsing files.
Append
When selected, additional files will be appended to the existing list without overwriting previous selections.
MaxSize
The file size can be limited using the MaxSize parameter (1 MB in this example).
AllowedExtensions
Limits file browsing by the provided file extensions.
Removable
Enables the remove functionality of the BitFileInput.
Events
Use OnChange to handle file selection and ReadContentAsync to access the file's byte array content.
Selected files:
Templates
The BitFileInput can be further customized using templates.
Drag and drop or
Browse files
Public API
Use custom methods to interact with the file input.
External Icons
Use icons from external libraries like FontAwesome and Bootstrap Icons with the RemoveButtonIcon parameter.
FontAwesome:
Bootstrap:
API
BitFileInput parameters
Name
Type
Default value
Description
Accept
string?
null
Accepted file types for the file browser using MIME types or file extensions (e.g., "image/*", ".pdf,.doc"). Applied to the underlying HTML input element's accept attribute.
AllowedExtensions
IReadOnlyCollection<string>
["*"]
Allowed file extensions for validation purposes (e.g., [".jpg", ".png", ".pdf"]). Use ["*"] to allow all file types. Files not matching these extensions will be marked as invalid.
Append
bool
false
Whether to append newly selected files to the existing file list instead of replacing it.
AutoReset
bool
false
Whether the file input is automatically reset (cleared) before opening the file browser dialog, allowing the same file to be selected multiple times consecutively.
Gets or sets the remove button icon using custom CSS classes for external icon libraries. Takes precedence over RemoveButtonIconName when both are set.
Gets or sets the visibility state (visible, hidden, or collapsed) of the component.
BitComponentBase public members
Name
Type
Default value
Description
UniqueId
Guid
Guid.NewGuid()
Gets the readonly unique identifier for the component's root element, assigned when the component instance is constructed.
RootElement
ElementReference
Gets the reference to the root HTML element associated with this component.
BitFileInputInfo properties
Represents metadata, validation state, and content of a file selected through BitFileInput.
Name
Type
Default value
Description
ContentType
String
string.Empty
The MIME content type of the file (e.g., "image/png", "application/pdf").
Name
String
string.Empty
The name of the file including its extension (e.g., "document.pdf").
Size
long
The size of the file in bytes.
FileId
String
string.Empty
A unique identifier (GUID) assigned to the file upon selection, used to reference the file in JavaScript interop.
Index
int
The zero-based index of the file in the current selection list.
IsValid
bool
true
Whether the file has passed all validation checks including size constraints and allowed extensions.
Message
string?
null
The validation error message when the file has failed a validation check (e.g., size or extension). This is null when the file is valid.
Content
byte[]?
null
The file content as a byte array, populated by calling ReadContentAsync. This is null by default and only loaded on demand.
BitIconInfo properties
Name
Type
Default value
Description
Name
string?
null
Gets or sets the name of the icon.
BaseClass
string?
null
Gets or sets the base CSS class for the icon. For built-in Fluent UI icons, this defaults to "bit-icon". For external icon libraries like FontAwesome, you might set this to "fa" or leave empty.
Prefix
string?
null
Gets or sets the CSS class prefix used before the icon name. For built-in Fluent UI icons, this defaults to "bit-icon--". For external icon libraries, you might set this to "fa-" or leave empty.
BitVisibility enum
Name
Value
Description
Visible
0
The content of the component is visible.
Hidden
1
The content of the component is hidden, but the space it takes on the page remains (visibility:hidden).
Collapsed
2
The component is hidden (display:none).
BitDir enum
Name
Value
Description
Ltr
0
Ltr (left to right) is to be used for languages that are written from the left to the right (like English).
Rtl
1
Rtl (right to left) is to be used for languages that are written from the right to the left (like Arabic).
Auto
2
Auto lets the user agent decide. It uses a basic algorithm as it parses the characters inside the element until it finds a character with a strong directionality, then applies that directionality to the whole element.
Feedback
You can give us your feedback through our
GitHub repo
by filing a new
Issue
or starting a new
Discussion.