File Upload

File Upload is a component that enables users to upload single or multiple files with validation, progress tracking, and customization options.

TypeResource
DesignFigma
MobileWeb Storybook
CodeGitlab

Overview

File Upload Preview

Usage

import id.co.biofarma.binduiandroid.components.single_file_upload.FileUpload
FileUpload(
    selectedFiles = remember { mutableStateOf(listOf()) },
    onUploadChange = { files -> 
        // Handle file changes
    },
    label = "Upload Document"
)

Examples

Single vs Multiple Upload

Choose between single file or multiple file upload modes.

File Upload Types

Size Variations

The component supports different sizes to match your design needs.

File Upload Sizes

Progress Tracking

Show upload progress with a built-in progress bar.

File Upload Single Upload Progress

States

The component supports various states including error and disabled.

File Upload State

Props

PropsRequiredDefaultTypeDescription
idfalse""StringUnique identifier for the component
selectedFilestruemutableStateOf(listOf())MutableState<List<File>>Currently selected files
onUploadChangetrue-(List<File>) -> UnitCallback when files are selected
disabledfalsefalseBooleanDisables the upload functionality
stylefalseModifierModifierCustom styles for the component
sizefalse"sm"StringComponent size: “sm”, “md”, “lg”
allowedFileTypesfalse["jpg", "png", "pdf"]List<String>Allowed file extensions
maxFileSizeInMBfalse5ByteMaximum allowed file size
showProgressfalsefalseMutableState<Boolean>Controls progress bar visibility
currentProgressfalse0MutableIntStateUpload progress percentage
remainingTimeInSecfalse0MutableIntStateRemaining upload time
helperTextfalse""StringHelper text below component
labelfalse""StringLabel above component
isErrorfalsefalseMutableState<Boolean>Error state flag
errorTextfalse""MutableState<String>Error message text
isMultiplefalsefalseBooleanEnable multiple file selection
onDeletefalse{}(File) -> UnitCallback when file is deleted

Guidelines

  1. File Types: Use allowedFileTypes to restrict uploads to specific formats.
  2. Size Limits: Set appropriate maxFileSizeInMB based on your requirements.
  3. Progress: For large files, enable showProgress to provide upload feedback.
  4. Error Handling: Use isError and errorText for validation feedback.
  5. Labels: Provide clear label and helperText for better user guidance.
BIND © Biofarma Innovate Next-level Design .