Skip to content

File upload

Single-file picker with a drag-and-drop target, format guidance, selected-file summary, and remove action.

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">↑</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>

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: Don't make drag-and-drop the only path — keep the native picker reachable by click and keyboard.

View in spec →