M Majid DS mds
GitHub

mds components

mds:file-upload

Drag-and-drop uploads — an open version of a Flux Pro component.

Upload images
You can pick several files at once.
<mds:file-upload name="photos" label="Upload images" description="You can pick several files at once." accept="image/*" multiple class="max-w-md">
    <mds:file-upload.dropzone
        heading="Drop your images here or click to browse"
        text="JPG, PNG or GIF up to 10 MB"
    />
</mds:file-upload>

Inline

A compact single-row dropzone, with an optional upload progress bar.

Compact
With a progress bar
<div class="w-full max-w-md space-y-4">
    <mds:file-upload name="invoice" label="Compact" accept="application/pdf">
        <mds:file-upload.dropzone heading="Drop a file, or click to choose" text="PDF only, up to 5 MB" inline />
    </mds:file-upload>

    <mds:file-upload name="attachment" label="With a progress bar">
        <mds:file-upload.dropzone heading="Add an attachment" text="Any format up to 20 MB" inline with-progress />
    </mds:file-upload>
</div>

File list

mds:file-item renders the chosen files. Give it a byte count and it formats the size — "159 KB" here, Persian units under a Persian config.

Profile_pic.jpg
159 KB
archive.zip
This file is over the 10 MB limit.
<div class="w-full max-w-md space-y-2">
    <mds:file-item heading="Profile_pic.jpg" image="https://picsum.photos/seed/phone/80/80" :size="162400">
        <x-slot name="actions">
            <mds:file-item.remove label="Remove Profile_pic.jpg" />
        </x-slot>
    </mds:file-item>

    <mds:file-item heading="archive.zip" text="This file is over the 10 MB limit." icon="exclamation-triangle" invalid>
        <x-slot name="actions">
            <mds:file-item.remove label="Remove archive.zip" />
        </x-slot>
    </mds:file-item>
</div>

Error and disabled

With a validation error
Disabled
<div class="w-full max-w-md space-y-4">
    <mds:file-upload name="broken" label="With a validation error" error="The selected file is over the size limit.">
        <mds:file-upload.dropzone heading="Product image" text="JPG or PNG up to 2 MB" inline />
    </mds:file-upload>

    <mds:file-upload label="Disabled" disabled>
        <mds:file-upload.dropzone heading="Uploading is unavailable" text="Place the order first" inline />
    </mds:file-upload>
</div>

Custom uploader

Any markup inside mds:file-upload gets the full upload behaviour. Style the states with the in-data-dragging: and in-data-loading: variants.

<mds:file-upload name="avatar" accept="image/*">
    <div class="relative flex size-20 cursor-pointer items-center justify-center rounded-full border border-zinc-200 bg-zinc-100 transition-colors hover:bg-zinc-200 in-data-dragging:border-accent dark:border-white/10 dark:bg-white/10">
        <mds:icon icon="user" class="text-zinc-500 dark:text-zinc-400" />

        <div class="absolute bottom-0 end-0 rounded-full bg-white dark:bg-zinc-800">
            <mds:icon icon="arrow-up-circle" class="size-5 text-zinc-500 dark:text-zinc-400" />
        </div>
    </div>
</mds:file-upload>

Persian output

config('mds.persian_digits') — on by default in a real app, off in these docs — switches the digits and the built-in strings (the dropzone's default heading, the remove button's label, the size units) to Persian. :fa="true" flips the upload progress on mds:file-upload and the size on mds:file-item; the dropzone has no fa prop, so this example passes its heading in Persian directly.

بارگذاری تصاویر
گوشی-گلکسی.jpg
۱۵۹ کیلوبایت
<div class="w-full max-w-md space-y-4">
    <mds:file-upload name="photos" label="بارگذاری تصاویر" accept="image/*" multiple :fa="true">
        <mds:file-upload.dropzone
            heading="فایل‌ها را اینجا رها کنید یا کلیک کنید"
            text="JPG، PNG یا GIF تا ۱۰ مگابایت"
        />
    </mds:file-upload>

    <mds:file-item heading="گوشی-گلکسی.jpg" image="https://picsum.photos/seed/phone/80/80" :size="162400" :fa="true">
        <x-slot name="actions">
            <mds:file-item.remove label="حذف فایل" />
        </x-slot>
    </mds:file-item>
</div>

Reference

mds:file-upload

PropDescription
nameField name, or the Livewire property to upload into.
labelField label.
descriptionSmaller text under the label.
acceptAccepted MIME types or extensions.
multipleAllows several files. Default: false.
errorValidation message shown under the control.
invalidMarks the control as invalid.
disabledDisables the control.
faPersian digits in the upload progress. Default: config('mds.persian_digits').
wire:modelBinds to a Livewire property for real uploads.

mds:file-upload.dropzone

PropDescription
headingMain line inside the dropzone. Default: "Drop a file here or click to browse", or the Persian equivalent — follows the config.
textSupporting line, usually the accepted types and size.
iconIcon name. Default: cloud-arrow-up.
inlineCompact single-row layout. Default: false.
with-progressShows the Livewire upload progress bar. Default: false.

mds:file-item

PropDescription
headingFile name.
textSecondary line. Derived from size when absent.
sizeByte count, formatted into a readable size — "159 KB", or ۱۵۹ کیلوبایت in Persian.
imageThumbnail URL.
iconIcon when there is no thumbnail. Default: document.
invalidMarks the file as rejected.
faPersian digits and size units. Default: config('mds.persian_digits').
SlotDescription
actionsButtons on the trailing edge, e.g. remove.

mds:file-item.remove

PropDescription
labelAccessible label. Default: "Remove file", or حذف فایل in Persian.
iconIcon name. Default: x-mark.

Related