Image Uploader
edgestore/image-uploaderFreeBlock
A component for uploading multiple images with preview grid and progress indicators.
Live preview
live · rendered by the registry
Rendered by EdgeStore on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://edgestore.dev/r/image-uploader.jsonSource
1'use client';23import { cn } from '@/lib/utils';4import { Trash2Icon, XIcon } from 'lucide-react';5import * as React from 'react';6import { type DropzoneOptions } from 'react-dropzone';7import { Dropzone } from './dropzone';8import { ProgressCircle } from './progress-circle';9import { useUploader } from './uploader-provider';1011/**12 * Props for the ImageList component.13 *14 * @interface ImageListProps15 * @extends {React.HTMLAttributes<HTMLDivElement>}16 */17export interface ImageListProps extends React.HTMLAttributes<HTMLDivElement> {18 /**19 * Whether the image deletion controls should be disabled.20 */21 disabled?: boolean;22}2324/**25 * Displays a grid of image previews with upload status and controls.26 *27 * @component28 * @example29 * ```tsx30 * <ImageList className="my-4" />31 * ```32 */33const ImageList = React.forwardRef<HTMLDivElement, ImageListProps>(34 ({ className, disabled: initialDisabled, ...props }, ref) => {35 const { fileStates, removeFile, cancelUpload } = useUploader();3637 // Create temporary URLs for image previews38 const tempUrls = React.useMemo(() => {39 const urls: Record<string, string> = {};40 fileStates.forEach((fileState) => {41 if (fileState.file) {42 urls[fileState.key] = URL.createObjectURL(fileState.file);43 }44 });45 return urls;46 }, [fileStates]);4748 // Clean up temporary URLs on unmount49 React.useEffect(() => {50 return () => {51 Object.values(tempUrls).forEach((url) => {52 URL.revokeObjectURL(url);53 });54 };55 }, [tempUrls]);5657 if (!fileStates.length) return null;5859 return (60 <div61 ref={ref}62 className={cn('mt-4 grid grid-cols-3 gap-2', className)}63 {...props}64 >65 {fileStates.map((fileState) => {66 const displayUrl = tempUrls[fileState.key] ?? fileState.url;67 return (68 <div69 key={fileState.key}70 className={71 'relative aspect-square h-full w-full rounded-md border-0 bg-muted p-0 shadow-md'72 }73 >74 {displayUrl ? (75 <img76 className="h-full w-full rounded-md object-cover"77 src={displayUrl}78 alt={fileState.file.name}79 />80 ) : (81 <div className="flex h-full w-full items-center justify-center bg-secondary">82 <span className="text-xs text-muted-foreground">83 No Preview84// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from EdgeStore
All 12 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Dropzonedropzone | EdgeStore | Blocks | Free | 2 deps | |
| File Uploaderfile-uploader | EdgeStore | Blocks | Free | 2 deps | |
| File Uploader Blockfile-uploader-block | EdgeStore | Blocks | Free | no deps | |
| Multi Image Uploader Blockmulti-image-uploader-block | EdgeStore | Blocks | Free | no deps | |
| Progress Bar Blockprogress-bar-block | EdgeStore | Blocks | Free | no deps | |
| Progress Circle Blockprogress-circle-block | EdgeStore | Blocks | Free | no deps | |
| Single Image Dropzone Blocksingle-image-dropzone-block | EdgeStore | Blocks | Free | no deps |
