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.
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.
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.
Kotlin Usage
1. Document Upload Dropzone with Scanner Integration
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
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
| Parameter | Type | Description | Default |
|---|---|---|---|
title * | String | Header title displayed inside the upload zone. | "Upload or scan document" |
allowedExtensions | List<String> | Permitted file format extensions. | listOf("PDF", "JPG", "PNG") |
maxSizeMb | Int | Maximum allowable file size per attachment in MB. | 5 |
uploadedFiles | List<Ux4gUploadedFile> | List of currently attached documents with their statuses. | emptyList() |
onUploadClick | () -> Unit | Callback triggered when the Upload button is pressed. | {} |
onScanClick | () -> Unit | Callback 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 |
enabled | Boolean | Controls interactive enabled state of the dropzone. | true |
modifier | Modifier | Compose layout modifier applied to the container. | Modifier |
Feedback Form
Comprehensive citizen feedback suite featuring 5-Star Ratings with improvement tags, CSAT sentiment face scales, and NPS (0-10) recommendation forms
Input Field
Standard Text Input, Password Field, Status States, Prefix/Postfix Affixes, Icons, Read-Only, Aadhaar Number, and PAN Input Field components