• CMSnpm version

    • Overview
    • ContentBuilder
    • InviteUserForm
    • LoginForm
    • RenewPasswordForm
    • WysiwygInput
  • UInpm version

    • Overview
    • Accordion
    • AlertBubble
    • AnnouncementBar
    • Avatar
    • AvatarFileInput
    • Badge
    • Button
    • ButtonGroup
    • ButtonList
    • Calendar
    • Checkbox
    • CheckboxButton
    • CheckboxInput
    • CheckboxList
    • Chip
    • ColorRadio
    • ColorRadioGroup
    • Combobox
    • DatePicker
    • DatePickerInput
    • DateRangePicker
    • DateRangePickerInput
    • DatetimePicker
    • DatetimePickerInput
    • Dialog
    • Dropdown
    • Dropzone
    • ErrorMessage
    • FileInput
    • FlashMessages
    • FormComponent
    • Icon
    • IconButton
    • ImageGallery
    • InfoBox
    • Input
    • Label
    • Layout
    • Lightbox
    • ListItem
    • Loader
    • Lozenge
    • Menu
    • Message
    • Modal
    • ✅ ModalDialog
    • ✅ ModalHeader
    • MultiCombobox
    • MultiSelect
    • Pagination
    • Paper
    • Popover
    • Radio
    • RadioGroup
    • RasterImage
    • Select
    • Switch
    • ✅ Tabs
    • TextInput
    • TextLink
    • Textarea
    • TimePicker
    • TimePickerInput
    • Toggle
    • Tooltip
    • Typography
  • Formnpm version

    • Overview
    • AvatarFileInput
    • CheckboxButton
    • CheckboxInput
    • CheckboxList
    • ColorRadioGroup
    • Combobox
    • DatePickerInput
    • DateRangePickerInput
    • DatetimePickerInput
    • Dropzone
    • FileInput
    • Form
    • FormRenderer
    • GpsInput
    • MoneyInput
    • MultiCombobox
    • MultiSelect
    • NumberInput
    • PasswordInput
    • RadioGroup
    • Select
    • TextInput
    • Textarea
    • TimePickerInput
    • Toggle
  • DataGridnpm version

    • Overview
    • DataGrid
    • DataGridCustomExample
    • ExportButton
    • FilterList
    • Filters
    • FiltersButton
    • FulltextInput
    • HiddenColumns
    • HiddenColumnsButton
    • Pagination
    • RowCounts
    • RowsPerPageSelect
    • SelectedRowsToolbar
    • TableV2
    • ToolbarControl
    • ToolbarCustoms
    • ToolbarTabs
  • Wysiwygnpm version

    • Overview
  • Resizernpm version

    • Overview
  • Routernpm version

    • Overview
  • Corenpm version

    • Overview
  • Core-Reactnpm version

    • Overview
  • DnDnpm version

    • Overview
  • Stylesnpm version

    • Overview
  • Localizenpm version

    • Overview
  • Analyticsnpm version

    • Overview
  • Datepickernpm version

    • Overview
  • Icons-generatornpm version

    • Overview
  • Smart-addressnpm version

    • Overview
  • E2Enpm version

    • Overview
  • E2E-Playwrightnpm version

    • Overview
View source on GitLab

FileInput

Single-file upload field: a labelled control with an upload button and the selected file name, wired to an async uploader.

When to use

Use FileInput for uploading one file behind a labelled form field. The file is uploaded immediately on selection via onUploadFile, and the resolved FileResponse is passed to onChange.

  • Inside a @uxf/form form: use @uxf/form/file-input instead — it wires react-hook-form (useController) and reads the form context (disabled/readonly/validation). @uxf/ui/file-input is the controlled primitive you drive yourself with value / onChange.
  • Multiple files or drag-and-drop: use Dropzone.
  • Avatar / image upload with a preview: use AvatarFileInput.

Usage

import { FileResponse } from "@uxf/core/types";
import { FileInput } from "@uxf/ui/file-input";
import { useState } from "react";

// your uploader: send the file to storage, resolve with the stored file
declare function uploadFile(file: File): Promise<FileResponse>;

function Example() {
    const [value, setValue] = useState<FileResponse | null>(null);

    return (
        <FileInput label="Attachment" name="attachment" onChange={setValue} onUploadFile={uploadFile} value={value} />
    );
}

Props

PropTypeDefaultDescription
valueFileResponse | null—Required. Currently selected file (controlled).
onChange(value: FileResponse | null, event?) => void—Required. Called with the uploaded file, or null when cleared.
onUploadFile(file: File, options?: UploadOptions) => Promise<FileResponse>—Required. Uploads the picked file; resolves to the stored file.
namestring—Required. Field name.
onUploadError(err: unknown) => void—Called when the upload throws or the file exceeds maxFileSize.
acceptstring—Native accept attribute (e.g. "image/*", ".pdf").
maxFileSizenumber—Max size in bytes; larger files reject with a max-size error before uploading.
labelReactNode—Field label.
helperTextReactNode—Helper / error text under the field.
hiddenLabelbooleanfalseKeep the label for a11y but hide it visually.
placeholderstring"No file has been selected yet"Text shown while no file is selected.
uploadButtonLabelstringtranslated "Upload file"Upload button text. Defaults to t("uxf-ui-file-input:upload-button-label").
isClearablebooleanfalseShow a remove button once a file is selected.
size"small" | "default" | "large""default"Field size.
variant"default""default"Visual variant.
isDisabledbooleanfalseDisable the field.
isReadOnlybooleanfalseRead-only (prevents changing the value).
isInvalidbooleanfalseInvalid styling and aria-invalid.
isRequiredbooleanfalseMark the field required.
isFocusedboolean—Force the focused styling.
onFocus / onBlurFocusEventHandler<HTMLInputElement>—Focus handlers.
idstringauto (useId)Input id; auto-generated if omitted.
formstring—Associate the input with a form by id.
classNamestring—Extra class on the root element.

size and variant come from the shared open interfaces InputGroupSizes / InputGroupVariants (@uxf/ui/input/theme); a project can add values via module augmentation.

Variants & states

  • Uploading: while the onUploadFile promise is pending, the field is disabled and a loader replaces the upload button label.
  • Clearable: with isClearable, a remove button appears once a file is set (hidden when disabled or read-only). Clearing resets the underlying input so the same file can be re-selected.
  • Download link: when rendered inside a UiContext that provides domain, the selected file name becomes a link to the stored file (opens in a new tab). Without that context it is plain text.

Requirements

Client component ("use client").

Import the required stylesheets once in your global CSS:

@import url("@uxf/ui/css/input-basic.css");
@import url("@uxf/ui/css/input.css");
@import url("@uxf/ui/css/label.css");
@import url("@uxf/ui/css/form-component.css");
@import url("@uxf/ui/css/file-input.css");

Also requires the global @uxf/ui token layer, set up once per app — see @uxf/ui setup.

Default
Open in new tab
Sizes
Open in new tab
States
Open in new tab