Forms

File drop

Takes files by dragging them in, pasting them or choosing them, and says plainly when one can't be used, even before it's dropped.

Installation

npx sinaui add file-drop

Examples

Several images

Pictures show a preview. Hold files over the box: it says whether they'll be taken before you let go. Files of the wrong type, too large, or over the limit are turned away with the reason.

Manuscript scans

Drag files here, or

Images up to 5 MB, four at most.

<script lang="ts">
	import FileDrop from '#lib/ui/FileDrop.svelte';

	let scans = $state<File[]>([]);
</script>

<FileDrop
	label="Manuscript scans"
	bind:value={scans}
	accept="image/*"
	multiple
	maxFiles={4}
	maxSize={5_000_000}
	hint="Images up to 5 MB, four at most."
	name="scans"
/>

One file

Without multiple, a new file replaces the old one.

Catalog

Drag a file here, or

One PDF. Choosing another replaces it.

<script lang="ts">
	import FileDrop from '#lib/ui/FileDrop.svelte';

	let catalog = $state<File[]>([]);
</script>

<FileDrop
	label="Catalog"
	bind:value={catalog}
	accept=".pdf"
	hint="One PDF. Choosing another replaces it."
/>

Props

PropTypeDefault
labelstring (required)
valueFile[], bindable[]
acceptstring, e.g. '.pdf,image/*'any
multiplebooleanfalse
maxSizenumber (bytes)
maxFilesnumber
namestring
hintstring
disabledbooleanfalse

The chosen files stay in a real file input, so a plain form submit sends them.

Accessibility

  • Dragging is a shortcut: the “choose” link opens the file picker by keyboard, touch or screen reader. With a pointer, pressing anywhere on the box does the same.
  • Files can be pasted too, once the box has focus.
  • Screen readers hear how many files were added, and why any were turned away.
  • Each file in the list has its own remove button, named after the file.
Introduction
Theming
Changelog
Button
Action button
Confirm button
Copy button
Hold to confirm
Split button
Calendar
Checkbox
Color picker
Combobox
Date picker
Date range picker
File drop
Form
Input
Mention input
Multi select
Number field
OTP input
Password input
Phone input
Radio cards
Radio group
Rich text editor
Search field
Segmented control
Select
Signature pad
Slider
Switch
Tag input
Upload
Wheel picker
Textarea
Time field
Toggle group
Toolbar
Alert dialog
Command palette
Context menu
Dialog
Drawer
Dropdown
Hover card
Popover
Tooltip
Announcement bar
Alert
Empty state
Meter
Progress
Rolling number
Skeleton
Spinner
Toast
Avatar
Avatar group
Badge
Card
Carousel
Chart
Chat
Code block
Data table
Folder
Kbd
Mind map
Resizable panels
Scroll area
Separator
Sortable
Table
Tag group
Virtual list
Audio player
Image
Image compare
Video
Visualizer
Breadcrumb
File tree
Menubar
Navigation menu
Pagination
Sidebar layout
Stepper
Tabs
Alarm clock
Clock
Dynamic island
Fluid orb
Hourglass
Stopwatch
Timer
AI chat
AI media
Auth
Board
Booking
Dashboard
File explorer
Messaging
Notifications
Settings
Team
Overview
Pricing
Agent chat
Calendar
Voice agent
Mail inbox
CMS
Blog
Marketing site
E-commerce
AI agents
SaaS landing page
SaaS app
Accordion
Dark theme
Light theme