Skip to content

feat: customisable composable components #910

@veloii

Description

@veloii

Describe the feature you'd like to request

I'd like to request unstyled, composable components for uploadthing:

  • Inline uploadable image component (e.g. for avatars)
  • Composable versions of existing file upload components

These would be bare-bones, allowing easy styling and flexible combinations. I've already had to build similar things for my own sites. This kind of stuff is gold for DX - saves time and headaches.

Describe the solution you'd like to see

I've already got an UploadableInlineImage component in my site at the moment. The other components would have a similar API.
All the components can be customised with your current styling solution, for the examples I'm using Tailwind.

Hierarchy:

<UploadableInlineImage>
	<UploadableInlineImageProgressOverlay />
	<UploadableInlineImageOverlay>
		<UploadableInlineImageEditButton />
		<UploadableInlineImageDeleteButton />
	</UploadableInlineImageOverlay>
	<UploadableInlineImageDropzone>
		<UploadableInlineImageContent  />
		<UploadableInlineImageEmpty />
	</UploadableInlineImageDropzone>
</UploadableInlineImage>

Example Usage:

<UploadableInlineImage
	endpoint="updateBanner"
	// all the props like onUploadError, onClientUploadComplete, etc could be here
	imageUrl={imageUrl}
	className="h-32 w-full md:h-auto md:rounded-xl outline outline-1 -outline-offset-1 outline-zinc-950/10 bg-white"
>
	<UploadableInlineImageProgressOverlay variant="bar" />

	<UploadableInlineImageDropzone className="transition data-[drag]:opacity-50">
		<UploadableInlineImageOverlay className="group-hover:opacity-100 opacity-0 transition w-full h-full bg-foreground/60 text-background border sm:rounded-xl flex flex-col gap-2 justify-center items-center">
			<Icons.media className="opacity-50" />
			<span>Select a photo</span>
		</UploadableInlineImageOverlay>

		<UploadableInlineImageContent
			draggable={false}
			className="object-cover"
			alt="Banner"
		/>

		<UploadableInlineImageEmpty>
			<div className="w-full h-full inline-flex flex-col gap-2 justify-center items-center">
				<Icons.media className="opacity-50" />
				<span>Select a photo</span>
			</div>
		</UploadableInlineImageEmpty>
	</UploadableInlineImageDropzone>
</UploadableInlineImage>

I'm not 100% sure on UploadableInlineImageProgressOverlay as that's currently not unstyled at the moment, but I think that could be worked out easily.

Additional information

No response

👨‍👧‍👦 Contributing

  • 🙋‍♂️ Yes, I'd be down to file a PR implementing this feature!

Metadata

Metadata

Assignees

No one assigned

    Labels

    PRs AcceptedAnyone feel free to pick this uparea:packagesissue regarding one of the uploadthing packages✨ enhancementsuggestion or feature request to improve uploadthing

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions