Skip to content

FileInput

One file chosen with a button: its name, its size and a way to remove it. For a drop zone, use FileDrop.

import { FileInput } from '@sypnia/ui/react'

On this page
  1. A signed contract
  2. When to use it
  3. For everyone
  4. Props

A signed contract

No file chosen

PDF, up to 10 MB.

Code
import { useState } from 'react';
import { Field, FileInput } from '@sypnia/ui/react';

// One file with a button; its name, size and a way to remove it.
export default function Invoice() {
  const [file, setFile] = useState<File | null>(null);
  return <Field label="Signed contract" hint="PDF, up to 10 MB."><FileInput file={file} onChange={setFile} accept="application/pdf" /></Field>;
}

When to use it

Use it when

  • A single document in a form.

Do not use it when

  • Several files or drag and drop: use FileDrop.
  • Images that need a preview: use ImageUpload.

For everyone

  • The button chooses; the remove button is named with the file.

Props

FileInputTypeDefault
filerequired File | null
onChangerequired (f: File | null) => void
accept string
disabled boolean
label string
  1. A signed contract
  2. When to use it
  3. For everyone
  4. Props

    Search pages, sections and terms