The File Input component renders a single-file form field with QDS input styling and file validation support.
import {FileInputModule} from "@qualcomm-ui/angular/file-input"Overview
The File Input component supports both click-to-browse and drag-and-drop interactions for a single file input. An advanced file upload component is currently in development and will support multi-file lists, async uploads, previews, and rejected-file workflows.
Examples
Simple
The simple <q-file-input> component bundles the label, input-like control, display text, clear trigger, hidden input, and error text into one component.
<q-file-input
class="w-full max-w-sm"
label="Upload file"
placeholder="Select a file"
startIcon="Upload"
/>
Composite
Use the composite API when layout or individual parts need explicit control.
<div
class="w-full max-w-sm"
q-file-input-root
startIcon="Upload"
[accept]="['.pdf']"
>
<label q-file-input-label>Upload agreement</label>
<div q-file-input-control>
<span placeholder="Select a PDF" q-file-input-display></span>
</div>
<input q-file-input-hidden-input />
</div>
Sizes
The File Input component supports three size variants: sm, md (default), and lg.
<div class="flex w-full flex-col items-center gap-6">
<q-file-input
class="w-full max-w-sm"
label="Upload file (Small)"
placeholder="Select a file"
size="sm"
startIcon="Upload"
/>
<q-file-input
class="w-full max-w-sm"
label="Upload file (Medium)"
placeholder="Select a file"
size="md"
startIcon="Upload"
/>
<q-file-input
class="w-full max-w-sm"
label="Upload file (Large)"
placeholder="Select a file"
size="lg"
startIcon="Upload"
/>
</div>
Errors
Set invalid and errorText for field-level validation messages. Configure file validation with properties such as accept, maxFileSize, and validate.
<q-file-input
class="w-full max-w-sm"
errorText="Upload a PDF file under 5 MB"
invalid
label="Tax document"
placeholder="Select a PDF"
required
startIcon="Upload"
[accept]="['.pdf']"
[maxFileSize]="5 * 1024 * 1024"
/>
Disabled
Set disabled on the simple component or root directive to prevent file selection and clearing.
<div class="flex w-full max-w-sm flex-col gap-4">
<label
label="I agree to the terms and conditions"
q-checkbox
[(ngModel)]="agreed"
></label>
<q-file-input
label="Upload approval"
placeholder="Select a file"
startIcon="Upload"
[disabled]="!agreed()"
/>
</div>
API
<q-file-input>
The <q-file-input> component extends the q-file-input-root directive with the following properties:
booleantrue, renders a clear button that resets the selected file on click.
The button only appears when a file has been selected.string<div q-file-input-error-text>...</div>
string<label q-file-input-label>...</label>
stringComposite API
q-file-input-root
FileAcceptTypeArray<File>
boolean| 'user'
| 'environment'
Array<File>
'ltr' | 'rtl'
booleanboolean| string
| LucideIconData
<div q-file-input-control>
<div q-input-end-icon [icon]="..."></div>
</div>
() =>
| Node
| ShadowRoot
| Document
stringbooleanstringnumbernumbernumberstringbooleanboolean| 'sm'
| 'md'
| 'lg'
| string
| LucideIconData
<div q-file-input-control>
<div q-input-start-icon [icon]="..."></div>
</div>
(
files: Array<File>,
) => Promise<Array<File>>
{
listLabel?: string
}
FileValidateFn{
files: Array<File>
}
FileDetailsFileRejectDetailsclass'qui-input__root'data-disableddata-draggingdata-file-upload-part'root'data-size| 'sm'
| 'md'
| 'lg'
q-file-input-label
stringclass'qui-input__label'data-disableddata-file-upload-part'label'data-requireddata-size| 'sm'
| 'md'
| 'lg'
q-file-input-control
booleanstringclass'qui-input__input-group'data-disableddata-draggingdata-file-upload-part'dropzone'data-focusdata-has-filedata-invaliddata-size| 'sm'
| 'md'
| 'lg'
tabIndex0q-file-input-display
stringclass'qui-input__input'data-size| 'sm'
| 'md'
| 'lg'
q-file-input-clear-trigger
class'qui-input__clear-trigger'data-file-upload-part'clear-trigger'data-invaliddata-size| 'sm'
| 'md'
| 'lg'
hiddenbooleanq-file-input-hidden-input
stringq-file-input-error-text
class'qui-input__error-text'data-file-upload-part'error-text'hiddenboolean