Dropzone
Files
<neura::dropzone />
Variants
variant is default, solid, card, minimal, cover, or avatar. Avatar is a circle: the camera sits in the empty state, and a scrim appears only once a photo is there.
Filled well
Raised card
Compact trigger
Wide banner
<neura::dropzone variant="solid" label="Solid" />
<neura::dropzone variant="card" label="Card" />
<neura::dropzone variant="minimal" label="Minimal" />
<neura::dropzone variant="cover" label="Cover" />
<neura::dropzone variant="avatar" accept="image/*" />
Several files
multiple keeps every file. compact-at switches the previews to a tight row once that many files are in. accept limits the picker, and max-size is the cap in megabytes.
JPG, PNG, or GIF. Up to 5MB each.
files a file
<neura::dropzone
label="Upload images"
description="JPG, PNG, or GIF. Up to 5MB each."
accept="image/*"
:multiple="true"
:compact-at="2"
:max-size="5"
/>
<neura::dropzone accept=".pdf,.doc,.docx" />
Livewire
wire:model. Validation errors on that property, including documents.*, mark the frame invalid. Submit with no file to see the message under the field.
<neura::dropzone
wire:model="documents"
accept=".pdf,.doc,.docx"
:multiple="true"
:max-size="5"
/>
<neura::error name="documents" />
use Livewire\WithFileUploads;
use Neura\Kit\Concerns\WithDropzone;
class DocumentUploader extends Component
{
use WithFileUploads, WithDropzone;
public $documents = [];
public function save()
{
$this->validate([
'documents' => 'required|array|min:1',
'documents.*' => 'file|mimes:pdf,doc,docx|max:5120',
]);
$paths = $this->storeDropzoneFiles('documents', 'uploads/documents');
$this->clearDropzone('documents');
}
}
WithDropzone
TemporaryUploadedFile instances. Use it when the field posts the chunked payload. A plain wire:model file does not need it.
| Property | Type | Default | Description |
|---|---|---|---|
| getDropzoneFiles($property) | DropzoneFiles | Every file as a collection. | |
| getDropzoneFile($property) | TemporaryUploadedFile|null | The single file, for an upload that is not multiple. | |
| storeDropzoneFiles($property, $path, $disk) | array | Stores every file and returns the paths. | |
| storeDropzoneFile($property, $path, $disk) | string|null | Stores one file and returns the path. | |
| clearDropzone($property) | void | Empties the field after you have stored the files. |
Invalid
:invalid="true" forces the error state. Leave it unset and wire:model turns it on when validation fails.
This frame is marked invalid.
files a file
<neura::dropzone :invalid="true" label="Upload documents" />
<neura::dropzone :preview="false" />
<neura::dropzone :removable="false" />
<neura::dropzone :chunk-size="2" :max-size="100" />
Props
| Property | Type | Default | Description |
|---|---|---|---|
| accept | string | image/* |
File types the picker allows. |
| variant | string | default |
default, solid, card, minimal, cover, or avatar. |
| size | string | config | xs, sm, md, lg, or xl. |
| maxSize | int | 10 |
Maximum size in megabytes. |
| multiple | bool | false |
Keep more than one file. |
| compactAt | int|null | null |
Switch previews to a compact row at this count. |
| preview | bool | true |
Show a preview of each file. |
| removable | bool | true |
Show the remove control on each preview. |
| label | string|null | null |
Text above the frame. |
| description | string|null | null |
Text under the label. |
| invalid | bool|null | null |
Force the error state. Unset follows wire:model errors. |
| chunkSize | int | 1 |
Upload chunk size in megabytes. |