UX4G Logo
Components

File Upload

Document attachment drag/picker zone with file extension checking, max file size enforcement, and upload progress

The UX4G File Upload component provides an intuitive document attachment dropzone and file management interface for uploading application forms, identity proofs, certificates, and attachments across citizen portals and mobile workflows.

Key Capabilities

  • Dual Interaction Modes: Support for standard file browsing (Upload) and camera-based document capture (Scan).
  • File Validation: Built-in enforcement for permitted file extensions (PDF, JPG, PNG) and maximum file size thresholds (e.g. 5 MB).
  • Status & Progress Indicators: Real-time visual feedback for in-progress uploads with percentage tracking, verified uploads with success badges, and failed uploads with retry actions.
  • Dynamic List Management: Seamless handling of single and multi-file attachments with one-tap removal and dynamic "Add More files" actions.

Import from com.ux4g.designsystemv1.components.fileupload.*.


Interactive Previews

1. Default Dropzone State

Initial upload zone prompting the user to upload or scan documents with allowed formats and file size limits.

Ux4gFileUpload (Default Dropzone)Jetpack Compose
UX4G File Upload Default State

2. Single File Uploaded State

Dropzone with an uploaded document card showing the file icon, name, description, verification badge, and an option to add more files.

Ux4gFileUpload (Single File Uploaded)Jetpack Compose
UX4G File Upload Single File State

3. Uploaded File Item Statuses Showcase

Visual showcase displaying the different lifecycle states for uploaded documents: in-progress upload with progress indicator, verified success state, and error state with retry action.

UX4G Uploaded File Types Showcase

Kotlin Usage

1. Document Upload Dropzone with Scanner Integration

DocumentUploadScreen.kt
import androidx.compose.foundation.layout.*
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.ux4g.designsystemv1.components.fileupload.Ux4gFileUpload

@Composable
fun DocumentUploadScreen() {
    Ux4gFileUpload(
        title = "Upload or scan document",
        allowedExtensions = listOf("PDF", "JPG", "PNG"),
        maxSizeMb = 5,
        onUploadClick = {
            // Launch document / media picker
        },
        onScanClick = {
            // Launch scanner activity or camera capture
        },
        modifier = Modifier.fillMaxWidth().padding(16.dp)
    )
}

2. Managing Multiple Uploaded Attachments

MultiDocumentAttachment.kt
import androidx.compose.foundation.layout.*
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.ux4g.designsystemv1.components.fileupload.Ux4gFileUpload
import com.ux4g.designsystemv1.components.fileupload.Ux4gUploadedFile
import com.ux4g.designsystemv1.components.fileupload.Ux4gFileType
import com.ux4g.designsystemv1.components.fileupload.Ux4gUploadStatus

@Composable
fun MultiDocumentAttachment() {
    var fileList by remember {
        mutableStateOf(
            listOf(
                Ux4gUploadedFile(
                    fileName = "Document_name.pdf",
                    description = "Description",
                    fileType = Ux4gFileType.PDF,
                    status = Ux4gUploadStatus.Success
                )
            )
        )
    }

    Ux4gFileUpload(
        title = "Upload or scan document",
        allowedExtensions = listOf("PDF", "JPG", "PNG"),
        maxSizeMb = 5,
        uploadedFiles = fileList,
        onUploadClick = {
            // Pick and attach additional documents
        },
        onScanClick = {
            // Add more files via camera scan
        },
        onRemoveFile = { removedFile ->
            fileList = fileList.filter { it != removedFile }
        },
        modifier = Modifier.fillMaxWidth().padding(16.dp)
    )
}

Parameters

ParameterTypeDescriptionDefault
title *StringHeader title displayed inside the upload zone."Upload or scan document"
allowedExtensionsList<String>Permitted file format extensions.listOf("PDF", "JPG", "PNG")
maxSizeMbIntMaximum allowable file size per attachment in MB.5
uploadedFilesList<Ux4gUploadedFile>List of currently attached documents with their statuses.emptyList()
onUploadClick() -> UnitCallback triggered when the Upload button is pressed.{}
onScanClick() -> UnitCallback triggered when the Scan / Add More button is pressed.{}
onRemoveFile((Ux4gUploadedFile) -> Unit)?Callback triggered when the remove (X) button is pressed on a file item.null
onRetryFile((Ux4gUploadedFile) -> Unit)?Callback triggered when the retry link is clicked on a failed file item.null
enabledBooleanControls interactive enabled state of the dropzone.true
modifierModifierCompose layout modifier applied to the container.Modifier

On this page