FileInput

FileInput preserves native file selection, FileList access, picker security, and form behavior without owning an upload workflow.

Overview and decision boundary

Use FileInput for native single or multiple file selection when the product owns everything that happens after selection.

Do not add upload requests, Dropzone behavior, previews, queues, progress, retry, storage, or product validation policy to FileInput.

Choose one PDF or image file.

import { Field, FileInput } from '@nerio-ui/ui';<Field label="Attachment" description="Choose one PDF or image file."><FileInput name="attachment" accept=".pdf,image/*" /></Field>

Installation and imports

Install the editable registry source, or use the matching package entrypoint when the product keeps Nerio as a workspace dependency.

pnpm exec nerio add file-inputimport { Field, FileInput } from '@nerio-ui/ui';

Usage

import { Field, FileInput } from '@nerio-ui/ui';<Field label="Attachment" description="Choose one PDF or image file."><FileInput name="attachment" accept=".pdf,image/*" /></Field>

Variants

VariantDescription
SingleDefault native single-file selection.
MultipleNative multiple selection without upload queue behavior.
Accept and capturePlatform hints that do not replace consumer validation.

Anatomy

SlotDescription
file-input-rootLayout wrapper for the input and decorative icon.
file-inputNative input, picker trigger, and browser file summary.
file-input-iconDecorative upload icon over the compact native selector.

States

StateBehavior
DefaultOne native file-selection control with browser-owned picker chrome.
MultipleThe native multiple attribute returns one FileList with every selection.
RequiredNative form validity requires a selection before submission.
Invalidaria-invalid and the shared danger boundary communicate an actual error.
DisabledThe native disabled attribute prevents selection and form submission.

Motion

  • Hover and focus transition through shared control motion tokens.
  • Reduced motion keeps every state visible without nonessential timing.

Accessibility

  • Use with Label or Field, aria-label, or aria-labelledby so the native file input has an accessible name.
  • The native input remains visible, focusable, and available to assistive technology; browser picker and security behavior stay platform-owned.
  • Supports accept, capture, multiple, name, form, required, disabled, aria-describedby, and native form reset.
  • Read FileList from event.currentTarget.files or the forwarded HTMLInputElement ref.
  • The public API rejects controlled value, defaultValue, readOnly, and alternate input types because browsers prohibit populating file selection.
  • Accept and capture are native picker hints; consumers own file validation and localized messages.
  • Uploads, Dropzone, previews, queues, progress, retries, persistence, and storage remain consumer or Pro responsibilities.

Review the shared responsibility and evidence boundaries in the Accessibility foundation alongside this component-specific contract. Use the Spacing & layout foundation for shared density, wrapping, overflow, reflow, and component-versus-product ownership guidance. The Color foundation, Typography foundation, and Localization foundation define the shared visual-role, text-resilience, direction, and locale boundaries used by component examples.

API

PropTypeDescription
acceptstringNative picker hint for file extensions or MIME types.
multiplebooleanAllows more than one selected file in FileList.
captureboolean | "user" | "environment"Native compatible-device capture hint.
name / form / required / disablednative propsForm ownership and validity behavior.
onChangeChangeEvent<HTMLInputElement>Reads event.currentTarget.files directly.
refHTMLInputElementAccesses files, validity, focus, and an intentional reset path.
sizesm | md | lgShared Core control geometry.
invalidbooleanNormalizes data-invalid and aria-invalid.

Implementation contract

ContractValue
Semantic rootNative input type=file
Entrypoint@nerio-ui/ui
StateNo mirrored FileList or hidden interactive input
ResetNative form reset, intentional remount, or direct empty ref value
BoundarySelection only; uploads and file workflows remain consumer or Pro work

Styling contract

ContractValue
AuthoringComplete, statically detectable Tailwind CSS v4 recipes own component visuals.
ValuesSemantic and component --n-* variables remain the canonical customization layer.
OverridesCustomizable slots merge consumer className values with tailwindCn so conflicting utilities resolve deterministically.
Residual CSSOnly shared keyframes and scoped no-Preflight compatibility rules remain; there is no parallel visual selector layer.

Design notes

  • FileInput is server-safe and renders one native input without mirrored selection state.
  • Browser file-picker chrome and security restrictions remain platform-owned.
  • Consumers may render localized file summaries outside the primitive from the change event.

Do / do not

Do
  • Provide a visible label and explain accepted formats nearby.
  • Read FileList from the change event or forwarded ref.
  • Validate files and localize summaries in consumer code.
Do not
  • Hide the native input from assistive technology or the tab order.
  • Programmatically populate a file value.
  • Add Dropzone, previews, queues, progress, retries, or storage to Core.

Tokens

These are the primary customization points. Override semantic or component tokens instead of changing component source.

TokenPurpose
--n-input-height-mdPublic customization point for this component contract.
--n-input-height-smPublic customization point for this component contract.
--n-input-height-lgPublic customization point for this component contract.
--n-input-radiusPublic customization point for this component contract.
--n-input-backgroundPublic customization point for this component contract.
--n-input-background-hoverPublic customization point for this component contract.
--n-input-borderPublic customization point for this component contract.
--n-input-border-hoverPublic customization point for this component contract.
--n-input-border-focusPublic customization point for this component contract.
--n-input-border-dangerPublic customization point for this component contract.
--n-input-foregroundPublic customization point for this component contract.
--n-input-disabled-backgroundPublic customization point for this component contract.
--n-input-disabled-foregroundPublic customization point for this component contract.
--n-file-input-button-gapPublic customization point for this component contract.
--n-file-input-divider-lengthPublic customization point for this component contract.
--n-file-input-button-sizePublic customization point for this component contract.
--n-file-input-button-backgroundPublic customization point for this component contract.
--n-file-input-button-background-hoverPublic customization point for this component contract.
--n-file-input-button-borderPublic customization point for this component contract.
--n-file-input-button-foregroundPublic customization point for this component contract.
--n-file-input-button-disabled-backgroundPublic customization point for this component contract.
--n-file-input-button-disabled-foregroundPublic customization point for this component contract.
--n-motion-hover-durationPublic customization point for this component contract.
--n-motion-focus-durationPublic customization point for this component contract.
--n-focus-ringPublic customization point for this component contract.