Skip to content
Okaapiأوكابي
Framework for the code
Theme
Okaapi on GitHub

Chapter 04 Fields

File field

The browser's own file input, with a label, hint and error, in a zone that also takes files dropped on it. The native button and file names stay, so it works with the keyboard, screen readers and phone cameras as usual.

Use it in Angular
import { FileFieldComponent } from '@okaapi-ui/angular';
// The value is a File[]. Writing null or [] to the control clears the input.

One file

accept limits what the picker offers. It cannot stop a drop, so check the type and size again on the server.

Or drop a file here

PDF, up to 5 MB.

Angular
<ui-file-field label="Invoice" accept=".pdf" hint="PDF, up to 5 MB." formControlName="invoice" />

Several files, with an error

Or drop photos here

Angular
<ui-file-field
  label="Photos of the damage"
  accept="image/*"
  multiple
  dropText="Or drop photos here"
  formControlName="photos"
  [error]="form.controls.photos.invalid ? 'Add at least one photo' : undefined"
/>

In Arabic

أو اسحب الملف هنا

Angular
<ui-file-field label="الفاتورة" dropText="أو اسحب الملف هنا" formControlName="invoice" />

When to use something else

If you needUse
Typed text or a link to a fileText field

Inputs

NameTypeDefaultWhat it does
labelstring — Required. The visible label, tied to the input.
acceptstring — File types the picker offers: '.pdf', 'image/*'.
multiplebooleanfalseAllows more than one file.
hint, errorstring — As for the text field.
dropTextstring'Or drop a file here' from labelsThe line under the button; pass the translated text.
testIdstring — data-testid on the input, for tests.

Keyboard and screen readers

KeysWhat they do
Enter or Space Open the file chooser.
  • The browser’s own file input: the button and the chosen file names are read as usual.
  • Dropping files is a shortcut; the button always works.