1.0.0 • Published 3 months ago
@thealamdev/filedropper v1.0.0
FileDropper
A React component for file uploading with drag-and-drop functionality, built with TypeScript, Tailwind CSS, and Framer Motion.
Installation
npm install filedropper
Usage
import { FileDropper } from 'filedropper';
import 'tailwindcss/tailwind.css'; // Make sure you have Tailwind CSS set up
function App() {
const handleFileChange = (fileInfo) => {
if (fileInfo) {
console.log(`File: ${fileInfo.name}, Size: ${fileInfo.size} bytes`);
} else {
console.log('File removed');
}
};
return (
File Upload Example
<FileDropper
width="600px"
height="400px"
acceptedFiles={["image/png", "image/jpg", "image/jpeg"]}
onFileChange={handleFileChange}
/>
);
}
export default App;
Props
Prop | Type | Default | Description |
---|---|---|---|
className | string | "" | Additional CSS classes |
width | string | "500px" | Width of the component |
height | string | "300px" | Height of the component |
acceptedFiles | string[] | ["image/png", "image/jpg", "image/jpeg", ".txt"] | Accepted file types |
onFileChange | function | undefined | Callback function called when a file is added or removed |
License
MIT
1.0.0
3 months ago