The goal of this package is to provide a simple and reusable file input component for React applications. It supports drag-and-drop functionality, pending states for each file, custom upload handlers and more.
npm install dn-react-file-inputThe goal of this package is to provide a simple and reusable file input component for React applications. It supports drag-and-drop functionality, pending states for each file, custom upload handlers and more.
``tsx
import { FileInputButton } from "dn-react-file-input";
export default function App() {
return (
How to add a drag and drop area
`tsx
import { FileInputArea } from "dn-react-file-input";export default function App() {
return (
Drag and drop files here or click to upload.
);
}
`How to get the list of files
`tsx
import {
useFiles,
useFileInputController,
FileInputArea,
} from "dn-react-file-input";export default function App() {
const controller = useFileInputController();
const files = useFiles({ controller });
return (
Drag and drop files here or click to upload.
{files.map((snapshot) => (
{snapshot.name} {snapshot.isLoading ? "Loading..." : "Loaded"}
))}
);
}
``