File
React Bootstrap 5 File component
File Input is a field which the user can use to upload one or more files (photos, documents or any other file type) from local storage.
Basic example
The file input is the most gnarly of the bunch and requires additional JavaScript if you’d like to hook them up with functional Choose file… and selected file name text.
Add the disabled
prop to the <MDBFile>
and the custom markup
will be updated to appear disabled.
Sizing
You may also choose from small and large file inputs to match our similarly sized text inputs.
Multiple example
You can choose multiple files with one input as well. Just add the
multiple
prop to the
<MDBFile>
File - API
Import
Properties
MDBFile
Name | Type | Default | Description | Example |
---|---|---|---|---|
disabled
|
Boolean | false |
Makes the MDBFile disabled |
<MDBFile disabled />
|
inputRef
|
String | '' |
Reference to input element |
<MDBFile inputRef={reference} />
|
id
|
String | '' |
Defines an id for the MDBFile |
<MDBFile label="Example label" id="inputExample" />
|
label
|
String | '' |
Defines a label text for the MDBFile |
<MDBFile label="Example label" id="inputExample" />
|
labelId
|
String | '' |
Defines an id for the label |
<MDBFile label="Example label" labelId="exampleLabel" id="fileExample" />
|
labelClass
|
String | '' |
Adds custom classes to the label |
<MDBFile label="Example label" labelId="exampleLabel" labelClass="test-class" id="fileExample" />
|
labelStyle
|
React.CSSProperties | undefined |
Adds custom styles to the label |
<MDBFile labelStyle={customStyles} labelId="exampleLabel" labelClass="test-class" id="fileExample" />
|
name
|
String | '' |
Specifies the name for the MDBFile |
<MDBFile name="sampleName" label="Example label" id="inputExample" />
|
size
|
String | '' |
Set size of the MDBFile |
<MDBFile size="lg" />
|