I followed the instructions on the page https://docs.uploadthing.com/nextjs/pagedir to upload images to uploadthing.com, and everything is working fine. Now I want to customize the upload button, so how can I do that?
Below is the code in my application:
import { UploadButton } from "~/utils/uploadthing";
export default function Home() {
return (
<main className="flex min-h-screen flex-col items-center justify-between p-24">
<UploadButton
endpoint="imageUploader"
onClientUploadComplete={(res) => {
// Do something with the response
console.log("Files: ", res);
alert("Upload Completed");
}}
onUploadError={(error: Error) => {
// Do something with the error.
alert(`ERROR! ${error.message}`);
}}
/>
</main>
);
}
Example: Can I replace the upload button with an image or SVG? If yes, how can I do that?
2
Answers
To do so, you need to update your
UploadButton
component. You can addsvg
orprogressbars
or anything you like.I would suggest you to use React Uploady. The tutorial you are using is very much dependent on the library and lot of details are encapsulated.