0.7.4 gives the Ambient pack weather. A page names one feed URL on its own site, and the pack sets data-weather from it, uses its sunrise and sunset for dawn and dusk, and never shows a stale observation. Helpers for producing the feed from Open-Meteo are included. Ambient p…
Turn a native file input into a drag-and-drop zone with a file list. Dropped files follow the input's accept and multiple rules; rejected files are announced.
Overview
data-upload wraps a native <input type="file"> in a drop zone that lists the chosen files by name and size. The input stays the real control: it is stretched transparently over the zone, so a click anywhere opens the file picker, it keeps the only tab stop, and it submits with the form.
Dropped files follow the same rules as the picker: the native acceptattribute filters them and, without multiple, only the first file is kept. Anything left out is announced in a status line.
Usage
Basic file upload
1234
<form-field><labelfor="resume">Resume (PDF or DOC)</label><inputtype="file"id="resume"name="resume"data-uploadaccept=".pdf,.doc,.docx"></form-field>
After setup the input sits inside this structure (the script builds it; you do not write it):
Generated structure
1234567891011
<divclass="upload-zone"><inputtype="file"id="resume"name="resume"data-uploadaccept=".pdf,.doc,.docx"aria-describedby="upload-1-prompt"><pclass="upload-prompt"id="upload-1-prompt"><svgaria-hidden="true">…</svg><span>Drag a file here or <spanclass="upload-browse">browse</span></span><small>PDF, DOC, DOCX</small></p><ulclass="upload-file-list"aria-label="Selected files"hidden></ul><pclass="upload-status"role="status"></p></div>
Words for image/*, audio/* and video/* in the accept hint. Extensions and exact types show as written (.pdf and application/pdf both read "PDF").
The data-label-* attributes go on the input. File sizes are formatted with Intl.NumberFormat in the language of the closest [lang], using decimal units (1 kB = 1000 bytes).
Behaviour
Selection replaces — each pick or drop replaces the previous selection, as the native input does. A drop where every file is rejected leaves the current selection alone.
Drag state — data-dragover is set on .upload-zone while files are dragged over it.
Reset — a form reset empties the file list and the status line.
Disabled — a disabled input ignores drops and the zone is dimmed.
No size or count limits — the script does not check file size or count. Enforce limits in your own change handler (with setCustomValidity) and on the server. accept is a hint the user can bypass; always validate type on the server too.
Events
No custom events. Picking files fires the native input and change events; a drop that accepts at least one file fires both too, after updating input.files.
No custom properties. Style the generated classes; these are the shipped rules that matter most:
Shipped upload zone rules (excerpt)
1234567891011121314151617181920212223
.upload-zone {border: 2px dashed var(--control-border, var(--color-border-strong));border-radius: var(--radius-m);padding: var(--size-l);}.upload-zone:hover,.upload-zone[data-dragover] {border-color: var(--color-interactive);}.upload-zone[data-dragover] {background: color-mix(in oklab, var(--color-interactive) 5%, transparent);}/* The transparent input cannot show focus, so the zone does */.upload-zone:has(input[type="file"]:focus-visible) {outline: var(--focus-ring-width, 2px) solid var(--focus-ring-color, var(--color-interactive));outline-offset: var(--focus-ring-offset, 2px);}.upload-browse { color: var(--color-interactive); text-decoration: underline; }.upload-status { color: var(--color-error-text); }
Other hooks: .upload-prompt (and its small), .upload-file-list li, .upload-file-name, .upload-file-size. In forced-colours mode the focus outline and the drag border use Highlight.
Accessibility
The native file input is the only control and the only tab stop. Its <label> names it; give it a visible one.
Keyboard focus on the input draws an outline around the whole zone. Enter or Space opens the picker, as on any file input.
The prompt, including the accepted types, is linked to the input with aria-describedby.
The browse cue is plain text, not a second button.
Rejected and dropped-extra files are announced through the role="status" line, which is also visible.
The file list is a labelled <ul> ("Selected files").
Drag and drop is never required: everything a drop does, the picker does too.
Without JavaScript the native file input renders as normal.
Examples
Accepted types
Try dropping a file of another type: it is left out and named in the status line.