Susegad UI Accessibility GitHub

How this site looks

The view settings need JavaScript. Every page reads well without them.

Mood

The same pages, in three moods.

Theme

Components

File drop

A native file input you can also drop files onto. Without JavaScript it is the browser's own input; with it, the real input covers a drop zone, and the element checks accept, size and count, lists each file with a Remove button, and says every change in words.

quiet warm playful

Open the live demo npx @susegad/cli add file-drop

Stands on: Core, Core: components, Sound, Tokens

The prompt

the prompt

Post your files: the letter goes into the box only when they are really kept.

A file input you can also drop files onto. Without JavaScript it is the browser's own file input and submits with the form. With it, the real input covers a drop zone. The element checks what the browser does not check on a drop, lists what was chosen, and says every change in words.

<link rel="stylesheet" href="susegad/components/file-drop/file-drop.css">
<script type="module" src="susegad/components/file-drop/file-drop.js"></script>

<form action="/send" method="post" enctype="multipart/form-data">
  <sg-file-drop max-size="10 MB">
    <label for="plans">Floor plans <span>PDF or JPG, up to 10 MB each</span></label>
    <input type="file" id="plans" name="plans" accept=".pdf,image/jpeg" multiple>
  </sg-file-drop>
</form>

The prompt

Build a file drop as a light-DOM custom element, <sg-file-drop max-size="10 MB">, around a native <label> and <input type=file>, so that without JavaScript it is the ordinary file input and the form sends the files. With JavaScript, move the label and input into a drop zone and stretch the input over the whole zone, transparent, so clicking, Enter and Space, and dropping onto it are all the browser's own, and show the input's focus on the zone. Also catch drops on the rest of the zone and put the files into the input itself, so the form still sends them. After every change, check what the browser does not check on a drop: the accept list read as the browser reads it, a size limit, and one file for an input without multiple. Keep what may stay by rebuilding the input's file list, and say in a status line what happened: "2 files chosen" and, for anything turned away, "setup.exe isn't a PDF or JPG, so it wasn't added." List each file with its size in words and a Remove button named for the file, and move focus to the next Remove button (or the input) when one goes. Give it three registers. Quiet: a dashed hairline zone that turns solid while a file is dragged over it, and nothing moves. Warm: a small pillar post box beside the words, with a letter waiting above the slot. It lifts to the slot while a file is dragged over, and is posted through the slot only when files are really kept, clipped so it vanishes at the slot. A turned-away file makes it shake. Playful: the letter drops in faster, the box gives a little as it lands, and three short marks say thunk. With reduced motion, change states without animation.

Words to code

When you sayTechniqueWhat happens
stretch the input over the whole zone, transparentnative firstThe real input lies over the zone with opacity 0. Every click, key and drop on it is the browser's own, and it stays in the form.
put the files into the input itselfinput.filesA drop elsewhere on the zone sets input.files = event.dataTransfer.files and fires change, so the form sends exactly what is listed.
the accept list read as the browser reads itpure matchingExtensions, image/* wildcards and exact types, ignoring case, in a pure function tested in Node. The browser's picker filters by accept; a drop does not, so the element does.
keep what may stay by rebuilding the input's file listDataTransferA new DataTransfer() holds the files that pass, and its files replaces the input's.
say in a status line what happenedlive regionOne role="status" line: the count, then a sentence for each file turned away, in the person's terms ("a PDF or JPG", "over 10 MB").
clipped so it vanishes at the slotSVG clip pathThe letter is clipped to the area above the slot. It slides down in front of the box and disappears exactly as it passes into it.
only when files are really keptmotion that follows the workThe letter is posted on a real change that kept at least one file, never on a timer or on hover alone.

<sg-file-drop> is a file input that also takes dropped files, checks them, lists them, and still works as a plain file input without JavaScript.

Usage

<link rel="stylesheet" href="susegad/components/file-drop/file-drop.css">
<script type="module" src="susegad/components/file-drop/file-drop.js"></script>

<form action="/send" method="post" enctype="multipart/form-data">
  <sg-file-drop max-size="5 MB">
    <label for="id">Photo ID <span>One photo, JPG or PNG, up to 5 MB</span></label>
    <input type="file" id="id" name="id" accept="image/jpeg,image/png" required>
  </sg-file-drop>
  <button>Send</button>
</form>

Put a <label for> and an <input type="file"> inside. Everything about what may be sent lives on the input: accept, multiple, required, name. The form sends the files the normal way.

Attributes, properties and events

NameWhat it does
max-sizeThe largest file allowed, like 10 MB, 500 KB or a number of bytes. Larger files are turned away with a sentence saying so.
handoffFor pages that take files the moment they arrive, like an uploader. The zone hands each choice or drop to the page and posts the letter; the page does the checking, listing and saying (the file-upload recipe uses its field note and progress list).
registerquiet, warm or playful; overrides the page's register.
remove(i) (method)Removes the file at index i.
sg-files (event)Fires after every change, with detail: { files, messages }.

Say the limits in the label's hint as well, for example "PDF or JPG, up to 10 MB each". The element also checks them, and says so if a file doesn't fit.

Registers

  • Quiet: a dashed hairline zone that turns solid while you drag a file over it. Nothing moves.
  • Warm: a pillar post box. The letter lifts to the slot while you drag a file over, and is posted when files are kept.
  • Playful: the letter drops in with a thunk.
  • Reduced motion: the states change without animation.

Accessibility

How this component meets WCAG 2.2 level A and AA, criterion by criterion, how each was checked, and what your page still owns.

  • Meets 19
  • Meets with author's part 2
  • Not applicable 1
CriterionStatusHow it was checked
1.1.1 Non-text contentMeetsThe post box and the drawn zone are aria-hidden="true" (packages/components/file-drop/skins/post.js; the visual prompt in packages/components/file-drop/file-drop.js too), and the label names the input. The words are real text: the status line and each file's name and size.
1.3.1 Info and relationshipsMeetsThe native <input type="file"> and its <label> stay in place; the list is a real <ul> and the status line a role="status" (file-drop.js). packages/components/file-drop/file-drop.check.mjs: "no JS: the native file inputs show, with their labels", "<register>: a chosen file is listed with its size".
1.3.5 Identify input purposeNot applicableA file chooser holds no personal data of a kind the criterion's list names.
1.4.1 Use of colorMeetsA file turned away is said in words ("setup.exe isn't a PDF or JPG, so it wasn't added", "huge-scan.pdf is over 10 MB"): file-drop.check.mjs, "a drop lands in the input; a wrong type is turned away, and said why", "a file over the limit is turned away".
1.4.3 Contrast (minimum)MeetsThe cue, list and status are --sg-text roles on the page surface: 12.6:1 light and 14.2:1 dark in the default palette (manual test, 2026-10-07, painted colours read from the demo), and 4.5:1 or more in every palette and theme in packages/tokens/tokens.test.js. Axe: tools/axe.mjs --url /packages/components/file-drop/demo.html, 0 violations across 6 runs (3 registers, light and dark), desktop, 2026-10-07. With two files chosen, one of them turned away, axe finds 0 violations in all three registers, light and dark (axe-core 4.13.0 run on that state, 2026-10-07).
1.4.4 Resize textMeetsManual test, 2026-10-07: demo with the root font size at 200 percent, three registers, no sideways scroll and nothing clipped (throwaway Playwright script).
1.4.10 ReflowMeetsManual test, 2026-10-07: demo at 320 CSS px, three registers, no sideways scroll (document width 320). With two files chosen at 390 px the page is still 390 wide.
1.4.11 Non-text contrastMeetsThe zone's dashed border is --sg-rule-strong: 3.66:1 against the page in light and 3.69:1 in dark in the default palette, in all three registers (manual test, 2026-10-07, painted colours). packages/tokens/tokens.test.js asserts 3:1 or more for the rule and the focus ring on every surface for every palette and theme.
1.4.12 Text spacingMeetsManual test, 2026-10-07: the WCAG text-spacing values (line height 1.5, letter 0.12em, word 0.16em, paragraph 2em) injected on the demo, three registers, no clipped or overlapping text (throwaway Playwright script). No check in the repository asserts it yet.
2.1.1 KeyboardMeetsfile-drop.check.mjs: "<register>: Tab reaches the real input, the zone shows focus, Space opens the chooser"; the Remove buttons are native buttons ("Remove takes the file out and keeps focus in the list"). Dragging is an extra way in, never the only one.
2.1.2 No keyboard trapMeetsManual test, 2026-10-07: packages/components/file-drop/file-drop.js binds no keydown and sets no tabindex; focus moves between native controls with Tab.
2.4.3 Focus orderMeetsfile-drop.check.mjs: after Remove, focus goes to the next Remove button, or back to the input ("Remove takes the file out and keeps focus in the list"); otherwise the order is the page's.
2.4.7 Focus visibleMeetstools/touch.check.mjs Tabs onto the control in each register and requires a focus style; file-drop.check.mjs requires the zone to show a ring when the input is focused.
2.4.11 Focus not obscured (minimum)Meets with author's partManual test, 2026-10-07: packages/components/file-drop/file-drop.css uses no position: fixed or sticky. A sticky header or banner the page adds can cover the zone or a Remove button that is scrolled to.
2.5.3 Label in nameMeetsThe input's name is the visible label, and a Remove button's name is "Remove <file name>" (file-drop.check.mjs, focus on "Remove garden.jpg"). The button shows a "×" symbol, not words, so there is no visible word for the name to contain; this is our reading of the criterion, not a checked fact.
2.5.7 Dragging movementsMeetsDropping files on the zone is optional: the input is stretched over the zone, so a click or tap opens the chooser, and each file has a Remove button (file-drop.check.mjs, "Tab reaches the real input ... Space opens the chooser"; "Remove takes the file out").
2.5.8 Target size (minimum)MeetsManual test, 2026-10-07, 390 px touch: the input that is the whole zone is 340 by 136 px in quiet and 340 by 157 px in warm and playful, and each Remove button is 44.0 by 44.0 px. No check in the repository asserts target size for the file drop yet.
3.2.2 On inputMeetsChoosing or dropping files only lists them and says so; it submits nothing and moves no focus (file-drop.check.mjs: "the form sends exactly the files listed" only once the form's own button is pressed).
3.3.1 Error identificationMeetsA rejected file is named and the reason said in the status line, whether it is the wrong type, too big, or one too many for a single-file box: file-drop.check.mjs, "a wrong type is turned away, and said why", "a file over the limit is turned away", "a single-file box keeps the first of several, and says so". A required input is stopped by the browser, with focus on the input ("required: the form waits for the photo ID, and focus goes to it").
3.3.2 Labels or instructionsMeets with author's partThe native <label> names the input (packages/components/file-drop/file-drop.check.mjs, "no JS: the native file inputs show, with their labels") and the zone says what it takes ("PDF or JPG", the size limit, from accept and max-size). The label text and what the files are for are the author's.
4.1.2 Name, role, valueMeetsThe control stays the native file input with its label; each Remove button has a name. Axe with JavaScript off: tools/axe.mjs --no-js --url /packages/components/file-drop/demo.html, 0 violations across 6 runs, 2026-10-07.
4.1.3 Status messagesMeetsOne role="status" line says how many files are chosen and why any were turned away, and says it again on Remove: file-drop.check.mjs, "a chosen file is listed with its size" (1 file chosen), "Remove takes the file out ... ground-floor.pdf removed."

The page author owns:

  • The label text and what the files are for, in the language of the page, and lang on a label in another language (3.1.2).
  • The accept and max-size the page asks for, and the page's own check on the server: the element only keeps files that match, and uploads nothing.
  • Sticky headers and banners that could cover the zone or a Remove button when it takes focus (2.4.11).
  • The colours the page sets behind the zone, if it overrides the tokens.

How it behaves

  • Without JavaScript it is the native file input, labelled by your label.
  • With JavaScript it is still the native input, stretched over the zone, so Tab reaches it, Space or Enter opens the file chooser, and the label names it. The zone shows its focus ring.
  • One status line says how many files are chosen and why any were turned away.
  • Each file in the list has a Remove button named for it ("Remove plan.pdf"). Removing one moves focus to the next Remove button, or back to the input.
  • required works as usual: the form waits, and focus goes to the input.
  • The post box is aria-hidden.

All 57 tables, and how the library tests

What moves, and why

The letter is posted only when files are really kept. Nothing is uploaded until the form is sent, so the element says "chosen", not "uploaded".