File Input
File inputs allow users to select and upload one or more files.
Component variations
Layout
Contains two variants: horizontal and vertical. Horizontal is Compact inline layout — ideal for form fields with limited vertical space. Vertical is Large centered dropzone — ideal for prominent file upload areas. Horizontal is the default layout.
Optional
Optional
Error State
Validation error styling applied to the dropzone and helper text.
File size exceeds the maximum allowed limit.
Disabled State
Interaction is prevented and the component is visually dimmed.
Without Label
The label row is omitted when no label, hint, or optional prop is provided.
Usage Guidelines
Import
Import the file-input component in your standalone component or module:
import-file-input.ts
Copy code
TypeScript Setup
Add the component to your imports and handle the filesChange output:
my.component.ts
Copy code
Basic Implementation
A minimal file input with label, supported types, and size constraint:
my.component.html
Copy code
Vertical Layout
Use layout="vertical" for a larger, more prominent dropzone:
my.component.html
Copy code
Error State
Set state="error" and provide a helperText for validation feedback:
my.component.html
Copy code
API Reference
Inputs
Property | Type | Default | Required | Description |
|---|---|---|---|---|
string | - | No | Field label displayed above the dropzone | |
string | - | No | Tooltip content shown on the help icon next to the label | |
boolean | false | No | Displays an "Optional" indicator on the right of the label row | |
'horizontal' | 'vertical' | 'horizontal' | No | Layout variant. horizontal = compact inline; vertical = large centered dropzone | |
string | - | No | list of supported file types | |
string | - | No | Maximum file size label shown in the footer (e.g. "12 MB") | |
boolean | false | No | Whether multiple files can be selected at once | |
boolean | false | No | Disables the component; prevents interaction and dims the UI | |
'error' | null | null | No | Validation state. "error" applies error styling | |
string | - | No | Helper/validation message displayed below the dropzone | |
string | - | No | Supporting text to show additional file size limit, file type etc |
Outputs
Event emitters for file interaction:
Property | Type | Description |
|---|---|---|
EventEmitter<File[]> | Emitted whenever the selected file list changes — on selection (click or drag-and-drop) and on removal. Always emits the full current list. |
Best Practices
When to Use
- Use File Input when this pattern clearly supports the user task.
- Use it to keep similar interactions consistent across the product.
When Not to Use
- Avoid using File Input when a simpler component communicates the same intent.
- Avoid using it when the pattern introduces unnecessary interaction steps.
Design Guidelines
- Always provide
supportedFilesandmaxSizeso users know what is accepted before uploading - Use
acceptto restrict the native file picker to valid types - Use
layout="horizontal"in forms andlayout="vertical"as a primary upload area - Show error state with
helperTextexplaining the issue (e.g. file too large, wrong type) - Use
hintTextfor additional context the user might need before selecting a file - Use
[multiple]="true"only when multi-file upload is intentionally supported - Handle the
filesChangeoutput to validate files before uploading - Keep labels, helper text, and actions concise and easy to scan.
- Use VD variants and states consistently for predictable behavior.
- Ensure keyboard access and clear focus order for accessibility.
Component playground
Customize the file input features in this section
Optional
example.html
Copy code