Dropzone
import { Dropzone } from '@hanzo/ui'
Default
Drag files onto the region, or click it to browse; each drop is added to the list below it.
Drag & drop files hereor click to browse (max 5 files, 5MB each)
export function Default() {
return <Dropzone />
}Images only
`accept` narrows what a drop or the file picker will take; anything else is rejected.
Drag & drop files hereor click to browse (max 5 files, 5MB each)
export function ImagesOnly() {
const [rejected, setRejected] = useState(0)
return (
<YStack gap="$2" width="100%">
<Dropzone
accept={{ "image/*": [".png", ".jpg", ".jpeg", ".gif", ".webp"] }}
onFilesRejected={(files) => setRejected((n) => n + files.length)}
/>
{rejected > 0 ? (
<Paragraph color="$color11">
{rejected} file{rejected === 1 ? "" : "s"} rejected — only images are accepted here.
</Paragraph>
) : null}
</YStack>
)
}Single file
`maxFiles={1}` keeps the list to the most recent drop.
Drag & drop files hereor click to browse (max 1 files, 5MB each)
export function SingleFile() {
return <Dropzone maxFiles={1} />
}Disabled
The region takes no drop and the picker will not open.
Drag & drop files hereor click to browse (max 5 files, 5MB each)
export function Disabled() {
return <Dropzone disabled />
}Types
export type DropzoneAccept = Record<string, string[]>export type DropzoneProps = {
className?: string
onFilesAccepted?: (files: File[]) => void
onFilesRejected?: (files: File[]) => void
maxFiles?: number
maxSize?: number
accept?: DropzoneAccept
disabled?: boolean
}Exports
Dropzonetype DropzoneAccepttype DropzoneProps