files-ui-main-logo
Files ui

FileCard

File cards are compact elements that represent a file in the UI. They can be used for just showing general info of the file, or either to allow the user to interact with them.

This widget allow users to see information of
Files
and / or trigger actions.

Basic FileCard

The FileCard component supports displaying information from a object or from given props.
Also, the
onDelete
prop is used to remove the file selection.
file created from props.jsx
28.00 MB
text/plain
<>
{value ? (
<FileCard {...value} onDelete={removeFile} />
) : (
<FileInputButton value={value ? [value] : []} onChange={updateFiles} />
)}
<FileCard {...sampleFileProps} />
</>
// file props
const sampleFileProps = {
id: ":0:",
size: 28 * 1024 * 1024,
type: "text/plain",
name: "file created from props.jsx",
};

Image preview

By setting the preview prop to
true
the component will show an image preview instead of a file icon.
To acomplish this task this component will take the imageUrlprop or will read the
File
object if given and if it is an image.
Finally, the
info
prop is used to show the complete information of the file.
blur Thor arrives wakanda.jpg
Thor arrives wakanda.jpg
28.00 MB
image/jpeg
<>
{value ? (
<FileCard {...value} onDelete={removeFile} info preview/>
) : (
<FileInputButton onChange={updateFile} accept="image/*"/>
)}
<FileCard {...sampleFileProps} info/>
</>
// file props
const sampleFileProps = {
id: "fileId",
size: 28 * 1024 * 1024,
type: "image/jpeg",
name: "Thor arrives wakanda.jpg",
imageUrl:"https://cdn.wallpapersafari.com/0/95/1zms6H.jpg"
};

Validation

The valid prop can be set to
true
,
false
or
undefined
.
file created from props.jsx
28.00 MB
text/plain
Not valid
valid file created from props.png
28.00 MB
image/png
File is too big. File type is not allowed.
Valid
non valid file created from props.jpg
28.00 MB
image/jpeg

Uploading status

The uploadStatus prop can be set to
"preparing"
,
"uploading"
,
"aborted"
,
"error"
or
"success"
. Also the uploadMessage prop is used for displaying the error or success message. Finally, the progress prop can be used to show the current progress of the upload process.
Each of the following examples demonstrates one state combination of the FileCard component.

preparing stage

preparing file.jsx
28.00 MB
text/plain
Preparing
preparing file.jsx
28.00 MB
text/plain
Preparing

uploading stage

uploading file.png
28.00 MB
image/png
Uploading
uploading file.png
28.00 MB
image/png
28 %
Uploading
uploading file.png
28.00 MB
image/png
Uploading
uploading file.png
28.00 MB
image/png
Uploading

upload result stage

upload aborted file.gif
28.00 MB
image/gif
Uploading
Upload was aborted by the user
upload with error file.jpg
28.00 MB
image/jpeg
Uploading
File couldn't be uploaded to Files-ui earthquakes. File was too big.
successfully uploaded file.png
28.00 MB
image/png
Uploading
File was uploaded correctly to Files-ui earthquakes

Actions: info, delete, see, watch, download

You can use the following actions.
  • FileCard with the onDelete prop will display a delete icon.
  • FileCard with the info prop will display an "info" icon that will display an info layer.
  • FileCard with the onSee prop will display the "see" button that can be used to retrieve an image
    URI
    obtained by reading a
    File
    object if given or just the
    imageUrl
    prop if given. In the first case, the file must be an image.
  • FileCard with the onWatch prop will display the "play" icon that can be used to retrieve the video as a
    File
    object if given or just the
    videoUrl
    prop if given. The file must be an video.
  • FileCard with the downloadUrl prop will display the "download" icon that can be used to start the download. If the onDownload prop is given, the "download" icon will also be visible, but it will be taken as the user will perform their own download.
Valid
actions sampleFile.jsx
28.00 MB
text/plain
Valid
actions sampleFile.jsx
28.00 MB
text/plain
blur actions sampleFile.jsx
Valid
actions sampleFile.jsx
28.00 MB
text/plain
Valid
actions sampleFile.jsx
28.00 MB
text/plain
Valid
actions sampleFile.jsx
28.00 MB
text/plain
Valid
actions sampleFile.jsx
28.00 MB
text/plain

Dark mode and Elevation

The FileCard component supports dark mode by setting the prop
darkMode
to
true
. The elevation can be used to establish a hierarchy between other content. In practical terms, the elevation controls the size of the shadow applied to the surface. In dark mode, raising the elevation also makes the surface lighter.
Valid
elevation=0.jsx
28.00 MB
text/plain
Valid
elevation=4.jsx
28.00 MB
text/plain
Valid
elevation=16.jsx
28.00 MB
text/plain
Valid
elevation=24.jsx
28.00 MB
text/plain
Valid
elevation=0.jsx
28.00 MB
text/plain
Valid
elevation=4.jsx
28.00 MB
text/plain
Valid
elevation=16.jsx
28.00 MB
text/plain
Valid
elevation=24.jsx
28.00 MB
text/plain

Smart image fit

FileCard with
smartImgFit
prop will display image according to its heigh and width.
Image with height greater than its width has a "portrait" orientation. Otherwise it has a "landscape" orientation.
blur (landscape)Thor arrives wakanda.gif
preview (landscape)Thor arrives wakanda.gif
(landscape)Thor arrives wakanda.gif
28.00 MB
image/gif
blur (landscape)Thor arrives wakanda.gif
(landscape)Thor arrives wakanda.gif
28.00 MB
image/gif
blur (landscape)Thor arrives wakanda.gif
(landscape)Thor arrives wakanda.gif
28.00 MB
image/gif
blur (portrait)Iron man in stark tower.gif
preview (portrait)Iron man in stark tower.gif
(portrait)Iron man in stark tower.gif
28.00 MB
image/gif
blur (portrait)Iron man in stark tower.gif
(portrait)Iron man in stark tower.gif
28.00 MB
image/gif
blur (portrait)Iron man in stark tower.gif
(portrait)Iron man in stark tower.gif
28.00 MB
image/gif

API

See the documentation below for a complete reference to all of the props available to the components mentioned here.