Dropzone
edgestore/dropzoneFreeBlock
A file dropzone component.
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/dropzone.jsonSource
1'use client';23import { cn } from '@/lib/utils';4import { AlertCircleIcon, UploadCloudIcon } from 'lucide-react';5import * as React from 'react';6import { useDropzone, type DropzoneOptions } from 'react-dropzone';7import { formatFileSize, useUploader } from './uploader-provider';89const DROPZONE_VARIANTS = {10 base: 'relative rounded-md p-4 w-full flex justify-center items-center flex-col cursor-pointer border-2 border-dashed border-muted-foreground transition-colors duration-200 ease-in-out',11 active: 'border-primary',12 disabled:13 'bg-muted border-muted-foreground cursor-default pointer-events-none opacity-50',14 accept: 'border-primary bg-primary/10',15 reject: 'border-destructive bg-destructive/10',16};1718/**19 * Props for the Dropzone component.20 *21 * @interface DropzoneProps22 * @extends {React.HTMLAttributes<HTMLInputElement>}23 */24export interface DropzoneProps extends React.HTMLAttributes<HTMLInputElement> {25 /**26 * Options passed to the underlying react-dropzone component.27 * Cannot include 'disabled' or 'onDrop' as they are handled internally.28 */29 dropzoneOptions?: Omit<DropzoneOptions, 'disabled' | 'onDrop'>;3031 /**32 * Whether the dropzone is disabled.33 */34 disabled?: boolean;3536 /**37 * Message shown when files are being dragged over the dropzone.38 */39 dropMessageActive?: string;4041 /**42 * Default message shown when the dropzone is idle.43 */44 dropMessageDefault?: string;45}4647/**48 * A dropzone component for file uploads that integrates with the UploaderProvider.49 *50 * @component51 * @example52 * ```tsx53 * <Dropzone54 * dropzoneOptions={{55 * maxFiles: 5,56 * maxSize: 1024 * 1024 * 10, // 10MB57 * }}58 * />59 * ```60 */61const Dropzone = React.forwardRef<HTMLInputElement, DropzoneProps>(62 (63 {64 dropzoneOptions,65 className,66 disabled,67 dropMessageActive = 'Drop files here...',68 dropMessageDefault = 'drag & drop files here, or click to select',69 ...props70 },71 ref,72 ) => {73 const { fileStates, addFiles } = useUploader();74 const [error, setError] = React.useState<string>();7576 const maxFiles = dropzoneOptions?.maxFiles;77 const maxSize = dropzoneOptions?.maxSize;78 const isMaxFilesReached = !!maxFiles && fileStates.length >= maxFiles;79 const isDisabled = disabled ?? isMaxFilesReached;8081 const {82 getRootProps,83 getInputProps,84 isDragActive,85 isFocused,86 isDragAccept,87 isDragReject,88 } = useDropzone({89 disabled: isDisabled,90// … truncated
What it pulls in
npm packages
Files it writes
More from EdgeStore
All 12 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| File Uploaderfile-uploader | EdgeStore | Blocks | Free | 2 deps | |
| File Uploader Blockfile-uploader-block | EdgeStore | Blocks | Free | no deps | |
| Image Uploaderimage-uploader | EdgeStore | Blocks | Free | 2 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 |
