Dropzone
A barebone area for receiving files or data via drag and drop events.
Props
Prop | Type | Default | Description |
|---|---|---|---|
data | File[] | string | undefined | The dropped data (files or text). Supports $bindable. |
mode | 'file' | 'text' | 'file' | Specifies the type of data the dropzone accepts. |
dropEffect | 'copy' | 'move' | 'link' | 'none' | 'copy' | The visual feedback during the drag operation. |
componentId | string | '' | The unique identifier for the component element. |
variant | string | '' | Custom CSS variant class. |
children | Snippet<[{ isDragOver: boolean; isInvalid: boolean }]> | required | Snippet for the dropzone content. Receives drag state. |
Samples
File Dropzone (Copy)
Optimized for file uploads. The cursor indicates a "Copy" operation.
Drag & Drop Files Here
0
<script>1
import { Dropzone } from 'fluid-ui-svelte/components';2
3
let droppedFiles = $state<File[]>([]);4
</script>5
6
<Dropzone bind:data={droppedFiles} mode="file" dropEffect="copy">7
{#snippet children({ isDragOver })}8
<div class="flex flex-col items-center gap-2">9
<p class="font-medium">10
{isDragOver ? 'Drop Files Now' : 'Drag & Drop Files Here'}11
</p>12
13
{#if droppedFiles.length > 0}14
<div class="mt-4 w-full text-left text-sm bg-neutral-100 p-2 rounded">15
<p class="font-bold mb-1">Dropped Files:</p>16
<ul class="list-disc pl-4">17
{#each droppedFiles as file}18
<li>{file.name} ({Math.round(file.size / 1024)} KB)</li>19
{/each}20
</ul>21
</div>22
{/if}23
</div>24
{/snippet}25
</Dropzone>Data Dropzone (Move)
Designed for moving text or data between applications. The cursor indicates a "Move" operation. This dropzone strictly rejects files.
Drag User Alice
Drag User Bob
Drag Draggable Elements or Text Here
0
<script>1
import { Dropzone } from 'fluid-ui-svelte/components';2
3
let droppedData = $state('');4
</script>5
6
<Dropzone bind:data={droppedData} mode="text" dropEffect="move">7
{#snippet children({ isDragOver })}8
<div class="flex flex-col items-center gap-2">9
<p class="font-medium">10
{isDragOver ? 'Drop Data Now' : 'Drag Text/Data Here'}11
</p>12
13
{#if droppedData}14
<div class="mt-4 w-full text-left text-sm bg-neutral-100 p-2 rounded border border-neutral-200">15
<p class="font-bold mb-1 text-primary-600">Captured Data:</p>16
<pre class="whitespace-pre-wrap">{droppedData}</pre>17
</div>18
{/if}19
</div>20
{/snippet}21
</Dropzone>