File Upload
Installation
Section titled “Installation”Copy editable source into an initialized application:
pnpm dlx @simurgh-ui/cli add file-uploadFor package consumption, import from the component subpath and load its optional recipe CSS:
import { FileUpload } from '@simurgh-ui/react/file-upload';import '@simurgh-ui/styles/file-upload.css';import { FileUpload } from '@simurgh-ui/vue/file-upload';import '@simurgh-ui/styles/file-upload.css';Angular
Section titled “Angular”import { FileUploadComponent } from '@simurgh-ui/angular/file-upload';import '@simurgh-ui/styles/file-upload.css';Omit the component stylesheet for fully headless styling. CLI-copied components use the local path
written to simurgh.json and the copied application styles instead of these package imports.
Purpose
Section titled “Purpose”File Upload keeps the platform file input as its focusable control while presenting a larger drop target. Selection and dropped files share the same accept filtering, single/multiple behavior, and polite filename announcement.
Default presentation: styled
Section titled “Default presentation: styled”The optional component stylesheet provides a complete default recipe, including visual hierarchy and interaction states. Consumers can override semantic tokens or omit the recipe.
Basic usage
Section titled “Basic usage”Anatomy
Section titled “Anatomy”The public component parts are listed in API surface below. Use only the parts needed by the example; compound components depend on their documented parent/child nesting.
State model
Section titled “State model”This component exposes no public controlled/uncontrolled state pair. Configure it through the props, events, native attributes, or parent-owned state documented in the API tables.
Treat accept as a convenience filter, not a security boundary; validate type, size, and contents on the server. Announce upload progress and errors separately after transfer begins. The component emits File[] and leaves transport, retries, previews, and removal policy to the application.
Examples
Section titled “Examples”<FileUpload label="Upload documents" description="PDF files only" accept=".pdf" multiple name="documents" onFilesChange={setFiles}/><FileUpload label="Upload documents" description="PDF files only" accept=".pdf" multiple name="documents" @files-change="files = $event"/><simurgh-file-upload label="Upload documents" description="PDF files only" accept=".pdf" name="documents" [multiple]="true" (filesChange)="files = $event"/>Real-world example: validated document upload
Section titled “Real-world example: validated document upload”Validate before transport and repeat validation server-side. The accept attribute is only a picker
hint; it does not prove file type or safety.
const MAX_BYTES = 5 * 1024 * 1024;function validateFiles(files: File[]) { const accepted = files.filter( (file) => file.type === 'application/pdf' && file.size <= MAX_BYTES, ); setErrors( accepted.length === files.length ? [] : ['Use PDF files up to 5 MB.'], ); setFiles(accepted);}<FileUpload label="Supporting documents" accept="application/pdf" multiple name="documents" onFilesChange={validateFiles}/>;Vue uses @files-change="validateFiles"; Angular uses (filesChange)="validateFiles($event)".
Announce errors and upload progress in a nearby live region.
Accessibility
Section titled “Accessibility”Preserve the documented composition and accessible names when wrapping or restyling this component. See accessibility and RTL guidance for keyboard, focus, labeling, and directionality requirements.
API surface
Section titled “API surface”- React exports:
FileUpload - Vue exports:
FileUpload - Angular exports:
FileUploadComponent
Import these public symbols from the component subpath shown in Installation. Framework-specific props, events, slots, directives, methods, defaults, and native-attribute behavior belong in the API tables on this page; use the linked source only to verify the current implementation.
React API reference
An inherited-attributes entry means the component accepts the complete named React native interface, including its event handlers and ARIA and data attributes. Remaining attributes are forwarded to the rendered element unless the component behavior described on this page overrides them.
FileUpload
Section titled “FileUpload”Complete props type: FileUploadProps.
| Prop | Type | Default / requirement |
|---|---|---|
children | ReactNode | undefined |
description | ReactNode | undefined |
label | ReactNode | Required |
onFilesChange | (files: File[]) => void | undefined |
Vue API reference
Boolean props without explicit defaults use Vue’s false default. Undeclared attributes follow
the fallthrough behavior stated for each component.
FileUpload
Section titled “FileUpload”Automatic fallthrough is disabled; attrs are manually forwarded to the rendered root.
| Prop | Type | Default / requirement |
|---|---|---|
label | string | Required |
description | string | 'Drop files here or browse' |
accept | string | undefined |
multiple | boolean | false |
disabled | boolean | false |
required | boolean | false |
name | string | undefined |
| Event | Payload |
|---|---|
files-change | File[] | never[] |
Slots: none.
Exposed methods: none.
Angular API reference
Angular
Section titled “Angular”Inputs and outputs use their public template names. Public methods are callable through a template
reference or ViewChild. Native attributes apply to the documented template root or directive host;
they are not automatically forwarded through component hosts.
FileUploadComponent
Section titled “FileUploadComponent”Component selector: simurgh-file-upload. The template’s first native element is label.
| Input | Type | Default / requirement |
|---|---|---|
inputId | string | createId('file') |
label | string | '' |
description | string | 'Drop files here or browse' |
accept | string | undefined |
name | string | undefined |
multiple | boolean | false |
disabled | boolean | false |
required | boolean | false |
| Output | Payload |
|---|---|
filesChange | File[] |
Content projection: none.
| Public method |
|---|
onChange(event: Event): void |
onDragover(event: DragEvent): void |
onDrop(event: DragEvent): void |
Composition contract
Section titled “Composition contract”Follow the framework example as a structural contract. Root components own shared state; parts that consume that state must stay under the root (or be attached to projected descendants in Angular). Parts described as conditional are optional until their corresponding interaction or semantic region is used. Do not render a state-consuming part by itself.
| Framework | Required parent/child relationship | Conditional parts | Supporting types |
|---|---|---|---|
| React | FileUpload is standalone and required when using this component. | Content is optional unless the API requires a label or value. | None. |
| Vue | FileUpload is standalone and required when using this component. | Content is optional unless the API requires a label or value. | None. |
| Angular | FileUploadComponent is standalone and required when using this component. | Content is optional unless the API requires a label or value. | None. |
Accessible names, descriptions, and form labels remain required whenever the component’s purpose cannot otherwise be determined, even when the corresponding visual part is optional.
Framework parity and differences
Section titled “Framework parity and differences”The adapters target the same user-visible behavior and accessibility contract. Their public shapes follow each framework’s conventions and are not expected to be symbol-for-symbol identical.
| Concern | Contract |
|---|---|
| Public composition | All adapters export 1 public symbol, with framework-idiomatic names. |
| State and change events | React uses controlled/default props and callbacks; Vue uses ordinary props/events; Angular uses [(files)]. |
| Children and content | React uses children; Vue uses the slots listed above; Angular uses the documented content projection selectors. |
| Native attributes | React forwards the named native interface; Vue follows the stated fallthrough rule; Angular attributes apply to the component host unless an input, directive, or documented native root consumes them. |
| Imperative access | React has no forwarded ref; Vue exposes no methods; Angular exposes the listed class methods through a template reference or ViewChild. |
These differences are intentional adapter design. Behavioral or accessibility differences not stated on this page are parity defects rather than supported variations.
Form integration
Section titled “Form integration”Use name="attachments" to serialize selected File objects using multipart form data. The examples initialize the field, keep its
value application-owned, forward disabled and required, render an accessible error, and read
the browser submission payload. This component has no public invalid prop; announce validation errors next to the labeled control and use native validity where available.
const initial = [];const [files, setFiles] = useState(initial);const [errors, setErrors] = useState<Record<string, string>>({});
<form onSubmit={(event) => { event.preventDefault(); const data = new FormData(event.currentTarget); // Submit data.get('attachments').}}> <FileUpload name="attachments" onFilesChange={setFiles} required disabled={isDisabled} /> {errors.attachments && <p role="alert">{errors.attachments}</p>} <button type="submit">Submit</button></form><script setup lang="ts">import { reactive, ref } from 'vue';const initial = [];const value = ref(initial);const errors = reactive<Record<string, string>>({});function submit(event: Event) { const data = new FormData(event.currentTarget as HTMLFormElement); // Submit data.get('attachments').}</script>
<form @submit.prevent="submit"> <FileUpload @files-change="value = $event" name="attachments" required :disabled="isDisabled"></FileUpload> <p v-if="errors.attachments" role="alert">{{ errors.attachments }}</p> <button type="submit">Submit</button></form>Angular
Section titled “Angular”initial = [];files = this.initial;errors: Record<string, string> = {};submit(form: HTMLFormElement) { const data = new FormData(form); // Submit data.get('attachments').}<form #form (submit)="submit(form); $event.preventDefault()"> <simurgh-file-upload (filesChange)="files = $event" name="attachments" required [disabled]="isDisabled"></simurgh-file-upload> <p *ngIf="errors.attachments" role="alert">{{ errors.attachments }}</p> <button type="submit">Submit</button></form>For Angular reactive or template-driven forms, bridge the documented value/valueChange pair
to your form control. The component does not implement ControlValueAccessor; update disabled and
validation state from the Angular form explicitly.
Supported states
Section titled “Supported states”The table distinguishes component behavior from application-owned presentation. “Not supported” means there is no public state contract for that adapter; do not invent one with an undocumented attribute. Keep status and error messages accessible when they are rendered outside the component.
| State | React | Vue | Angular |
|---|---|---|---|
| Loading | Not supported by this component API; handle this state in surrounding application UI. | Not supported by this component API; handle this state in surrounding application UI. | Not supported by this component API; handle this state in surrounding application UI. |
| Empty | Not supported by this component API; handle this state in surrounding application UI. | Not supported by this component API; handle this state in surrounding application UI. | Not supported by this component API; handle this state in surrounding application UI. |
| Invalid | Not supported by this component API; handle this state in surrounding application UI. | Not supported by this component API; handle this state in surrounding application UI. | Not supported by this component API; handle this state in surrounding application UI. |
| Read-only | Not supported by this component API; handle this state in surrounding application UI. | Not supported by this component API; handle this state in surrounding application UI. | Not supported by this component API; handle this state in surrounding application UI. |
| Disabled | Not supported by this component API; handle this state in surrounding application UI. | Supported with :disabled="true" on the documented control or interactive part; its interaction is blocked. Disabled form controls are omitted from submission. | Supported with [disabled]="true" on the documented control or interactive part; its interaction is blocked. Disabled form controls are omitted from submission. |
| Error | Not supported by this component API; handle this state in surrounding application UI. | Not supported by this component API; handle this state in surrounding application UI. | Not supported by this component API; handle this state in surrounding application UI. |
Styling contract
Styling contract
Section titled “Styling contract”The selectors below are used by the published component recipe or emitted consistently by an adapter. Treat these as the supported styling surface. Element order, anonymous wrappers, and undocumented descendants are implementation details and should not be targeted.
| Surface | Stable hooks |
|---|---|
| Recipe classes | No component-specific recipe class; this stylesheet currently imports shared tokens only. |
| Stable DOM parts | [data-slot="file-upload"], [data-slot="file-upload-description"], [data-slot="file-upload-input"], [data-slot="file-upload-label"], [data-slot="file-upload-status"] |
| Stable data attributes | [data-disabled], [data-slot] |
| ARIA/state selectors used by the recipe | No ARIA state selector is used by this recipe. |
| CSS custom properties consumed | --simurgh-accent, --simurgh-border, --simurgh-foreground, --simurgh-muted-foreground, --simurgh-ring, --simurgh-surface |
Prefer a semantic token override for theme-wide changes. Use the listed class or part selectors for a component-scoped override. When omitting recipe CSS, preserve state attributes and ARIA semantics even if your replacement styles use different selectors.
Customization
Section titled “Customization”Load the optional component stylesheet for the default recipe, override semantic tokens for broad theme changes, or omit the recipe CSS for headless styling. See theming and styling hooks for import order, selectors, dark mode, RTL, and reduced-motion guidance.
Last verified on 2026-08-13 against Simurgh registry 0.1.1.
Related components
Section titled “Related components”- Review the shared accessibility and RTL guidance and theming and styling hooks.
- Use the component chooser and component overview to compare related primitives.
- Inspect the registry manifest and framework source for React, Vue, or Angular.