Drop zone — Files block

Pro

files-drop-zone · for forms, app pages

Drop zone

A form that takes files by drop or choice within stated limits, then lists what was added

Documentation

Installation

One command copies the block into your project with the shadcn CLI (the registry is set once: Installation).

pnpm dlx shadcn-vue@latest add @trame/files-drop-zone

Usage

Its demo data, shortened (Using blocks).

<script setup lang="ts">
import FilesDropZone from '@/components/trame/blocks/files/files-drop-zone.vue'

const props = {
title: "Add documents",
limits: "PDF, JPG or PNG · up to 5 files · 10 MB each",
accept: ".pdf,image/jpeg,image/png",
maxFiles: 5,
maxSize: 10485760,
submit: "upload",
fields: [
{
name: "project",
label: "Project name",
placeholder: "Kitchen remodel",
required: true
},
{
name: "note",
label: "Message",
type: "textarea",
help: "Optional. Visible to the team receiving the files."
}
],
files: [
{
id: 1,
name: "kitchen-quote.pdf",
size: "2.4 MB"
},
{
id: 2,
name: "site-plan.png",
size: "860 KB",
progress: 64
}
],
options: {
cancel: "back"
}
}
</script>

<template>
<FilesDropZone v-bind="props" />
</template>

Props

Each prop says who changes it: Words, Picture, Action, Design, Data.* required.

PropTypeDescription
title*stringWordswhat is being uploaded ("Add documents")
limits*stringWordsthe limits as the server enforces them ("PDF, JPG or PNG · 5 files · 10 MB each")
acceptstringDesignthe file types the input accepts, as an accept attribute (".pdf,image/*")
maxFilesnumberthe most files at once
maxSizenumberthe most bytes per file
fieldsField[]the form’s fields, in order
filesFile[]Datathe files already chosen or being sent, with their real progress
submit*stringActionthe page action that receives the files
optionsOptionsthe block’s settings: layout choices and secondary words, read by every variant
Field fields[] · 7 props
PropTypeDescription
name*stringDesignthe key of the field in what the form sends
label*stringWordsthe field’s name ("Project name")
type'text' | 'email' | 'date' | 'textarea' | 'select'what kind of field it is: text, email, date, textarea, select
helpstringWordsone sentence on how the field is used
placeholderstringWordsthe shape expected, never a value that looks real
optionsOption[]the choices, for a select
requiredbooleantrue: it must be filled in
Option fields[].options[] · 2 props
PropTypeDescription
value*stringDesignwhat is sent
label*stringWordswhat is read
File files[] · 6 props
PropTypeDescription
id*string | numberthe file’s id
name*stringWordsthe file’s name
sizestringWordsits size as the app writes it ("2.4 MB")
progressnumberthe real upload progress, in percent; absent once finished
errorstringWordswhy it was refused, naming the limit
removestringActionremoves the file
Options options · 3 props
PropTypeDescription
cancelstringActionwhere Cancel leads
submitLabelstringWordsthe send button ("Upload")
mood'inverse' | 'brand' | 'warm' | 'tint' | stringa band of the page that redefines the theme surfaces inside it
What it asks your app for

The block never knows your app: it asks it, through one context provided once, where its links lead, what its actions do, how a price reads and which words to say (The host context).

MemberWhat it is for
hrefthe address an action leads to, or null to hide what leads there
actruns a change (subscribe, add to cart, save) and answers { ok } or { ok: false, error }
canwhether the page has this action
Linkyour router’s link component
cartCountthe cart badge’s number
cartDrawerwhether your app has a cart drawer
cartOpenwhether the cart drawer is open
labelyour word for an interface key, or undefined to keep the block’s own

The words it says itself, in English and French; label(key) replaces any of them:

KeyEnglishFrench
newsletter.alreadyYou are already subscribed.Vous êtes déjà inscrit.
newsletter.doneDone: you are subscribed.C’est noté : vous êtes inscrit.
newsletter.invalidCheck the email address.Vérifiez l’adresse e-mail.
newsletter.tooManyToo many attempts, try again in a moment.Trop de tentatives, réessayez dans un moment.

Features

  • Every word in the server HTML
  • Same markup in Vue and React
  • Theme tokens only: every theme, light and dark
  • Shows what you give it, invents nothing
  • No motion; still under reduced motion
  • Real buttons and links, a visible focus
  • Asks your app through actions: files[].remove, submit, options.cancel

A files section, for forms, app pages; it uses @lucide/vue, @vueuse/core, class-variance-authority, clsx, reka-ui, tailwind-merge.

Built with

The components this block is made of; each one installs on its own too.

More files blocks

  • Asset inspector wall beside: the same wall with the selected asset’s record beside it: weight, dimensions, where it is used, and its actions.
  • Device sync cards: Device status cards and folder sync controls, using the merchant's own sync states only.
  • Import mapping stepped: the import in numbered steps: match each column to a field, choose the duplicates to merge when there are any, review and send.
  • List browser: A file browser with list and grid views, using the merchant's own files only.
  • List links: A shared-file ledger with access and expiry, using the merchant's own system values only.
  • Media library grid: a wall of previews with a box on each to pick several assets at once, and the upload entry at hand.
  • Media library table: a dense table when there are many files: a small preview, the name and folder, the kind, the weight, the date.
  • Recent dated list: A date-grouped reading list for returning to the merchant's own recently used files, in host order.

All 12 files blocks