Skip to content

File upload

Single-file selection or multiple-file/folder intake with a drag-and-drop target, format guidance and accessible native picker.

View as Markdown

Preview

Knowledge source Controlled file selection with a visible accepted-format hint.

<div class="nx-upload">
  <label class="nx-upload__dropzone">
    <span class="nx-upload__icon" aria-hidden="true">
      <svg width="24" height="24" viewBox="0 0 24 24" fill="none"
          stroke="currentColor" stroke-width="2">
        <path d="M12 16V4m-4 4 4-4 4 4M4 16v4h16v-4"/>
      </svg>
    </span>
    <strong
        class="nx-upload__title">Choose a knowledge source</strong>
    <span class="nx-upload__hint">Drop a file here or browse</span>
    <span
        class="nx-upload__formats">PDF, TXT, MD · up to 25 MB</span>
    <input class="nx-upload__input" type="file"
        accept=".pdf,.txt,.md">
  </label>
</div>

Variants

Finished campaign media

NxFileDropzone collects files or a folder for review; applications enforce counts, formats and sizes before upload.

<div class="nx-upload nx-file-dropzone">
  <label class="nx-upload__dropzone">
    <strong class="nx-upload__title">Choose campaign files</strong>
    <span class="nx-upload__hint">Drop images and videos here or
        choose multiple files</span>
    <span class="nx-upload__formats">Up to 30 files · 50 MB
        each</span>
    <input class="nx-upload__input" type="file" multiple
        accept="image/*,video/mp4">
  </label>
  <button class="nx-btn nx-btn--ghost"
      type="button">Choose folder</button>
</div>

API

React props (NxKit)

React (NxKit) props
PropTypeDefaultRequiredDescription
titleReactNodeRequiredPrimary picker instruction.
hintReactNodeundefinedShort drop/browse instruction.
formatsReactNodeundefinedAccepted formats and size limit shown to users.
fileFile|nullRequiredControlled selected file.
onFileChange(file:File|null)=>voidRequiredReceives picker, drop, and remove changes.
removeLabelstringRequiredAccessible name for the remove button.
acceptstringundefinedNative picker accept filter; server-side validation remains required.

Classes

Framework-agnostic classes
ClassDescription
.nx-uploadStack wrapper
.nx-upload__dropzoneDashed, accent-reactive picker target
.nx-upload__inputVisually hidden native file input
.nx-upload__fileSelected-file summary
.nx-upload__removeAccessible remove action

States

dragging

disabled

Accessibility

  • The native file input remains in the accessibility tree; :focus-within paints a visible focus ring around the whole drop target.
  • Visible format and size guidance does not replace server-side type/size validation or a surfaced error message.

Do / Don’t

  • Do: State accepted formats and the size limit before selection, then show the chosen filename and size.Don't make drag-and-drop the only path. Keep the native picker reachable by click and keyboard.

View in spec