Slab
Slab

Form

File Drop

A file input you can also drop files onto. One list of files, either way.

Element
<slab-file-drop>
Built on
<input type=file>

Example

Here's a styled version, <slab-styled-file-drop>. It's not in the package — it's an example of what you can build with the headless element. Copy it and make it yours at the bottom of this page. Switch to "As it ships" to see the same markup with the headless element and no CSS at all. That's your starting point.

Styled example As it ships
Photos of the forms and the rebar, for the inspector.
HTML
<slab-styled-file-drop label="Site photos" accept="image/*" multiple>
  <span slot="description">Photos of the forms and the rebar, for the inspector.</span>
</slab-styled-file-drop>
Photos of the forms and the rebar, for the inspector.
HTML
<slab-file-drop label="Site photos" accept="image/*" multiple>
  <span slot="description">Photos of the forms and the rebar, for the inspector.</span>
</slab-file-drop>

Usage

Install
pnpm add slab-elements lit
ReactLitVueSvelteEmberHTML
import 'slab-elements/file-drop.js';

export function MyFileDrop() {
  return (
    <slab-file-drop label="Attachments" name="attachments" multiple></slab-file-drop>
  );
}

MyFileDrop.jsx React 19 or later, which sets props on custom elements as properties.

import 'slab-elements/file-drop.js';
import { html, LitElement } from 'lit';
import { customElement } from 'lit/decorators.js';

@customElement('my-file-drop')
export class MyFileDrop extends LitElement {
  render() {
    return html`
      <slab-file-drop label="Attachments" name="attachments" multiple></slab-file-drop>
    `;
  }
}

my-file-drop.ts Slab is built on Lit, so its elements are at home in Lit's templates.

<script setup>
import 'slab-elements/file-drop.js';
</script>

<template>
  <slab-file-drop label="Attachments" name="attachments" multiple></slab-file-drop>
</template>

MyFileDrop.vue Let Vue's compiler know slab- tags are custom elements with isCustomElement.

<script>
  import 'slab-elements/file-drop.js';
</script>

<slab-file-drop label="Attachments" name="attachments" multiple></slab-file-drop>

MyFileDrop.svelte Svelte binds properties and events to custom elements like any other element.

import 'slab-elements/file-drop.js';

export const MyFileDrop = <template>
  <slab-file-drop label="Attachments" name="attachments" multiple></slab-file-drop>
</template>;

MyFileDrop.gjs Ember sets attributes, and a dynamic value like {{this.max}} sets the property when the element has one. {{on}} listens for any event by its name.

<script type="module">
  import 'slab-elements/file-drop.js';
</script>

<slab-file-drop label="Attachments" name="attachments" multiple></slab-file-drop>

index.html Any bundler (or an import map) takes care of the imports.

A drop is held to what the picker would allow: files that don’t match accept are left out, and without multiple, a drop of several files is ignored. A drop has no picker to say what happened, so screenreaders are told how many files were added and how many were left out. Change what they’re told with addedLabel and notAcceptedLabel, functions of the count, and too-many-label.

Keyboard

Key What it does
Enter, Space Opens the browser’s file picker, as on a file input.

Behavior

A file input with no visual styles that files can also be dropped onto, around a native <input type="file">, so it is picked from, focused, and read the way one is.

Files dropped anywhere on the host go into the input's own files, the same list the picker fills, so there is one list and one source of truth. A drop dispatches "input" and "change" the way picking does.

Validity is the native input's, as with Text Field: required is passed through and valueMissing is mirrored onto the host.

A drop is held to what the picker would allow. Dropped files that don't match accept are left out, and without multiple, a drop of more than one file is ignored, as a browser ignores it on a native file input.

A drop has no picker to say what happened, so screenreaders are told: how many files were added, by addedLabel, how many were left out for not matching accept, by notAcceptedLabel, and when a drop of several files was ignored, by too-many-label. A drop that adds nothing is told assertively, since it's an error.

With no files, it submits one empty file under its name, as a native file input does.

Style it through its parts and through :state(disabled), :state(drag-over), :state(error) and :state(required). What the drop target looks like, and how big it is, is left to the styles around it.

API

<slab-file-drop>

Attributes
Name Type Default Description
label Required string Names it. It's the accessible name, and the visible label where there is one.
accept string Passed to the picker. Dropped files that don't match it are left out.
disabled boolean false Disables it, as disabled does a native control: the user can't focus or use it, and a form control's value isn't submitted.
hide-label boolean false Hides the label visually and leaves it as the accessible name, for a design that shows the label some other way.
multiple boolean false Without it, a drop of several files is ignored, as a native file input ignores it.
name string '' The name its value is submitted under, as a native control's name.
required boolean false Makes it invalid while it has no value, as required does a native control.
too-many-label string What screenreaders are told when a drop of several files is ignored, without multiple. "Only one file can be added" in English when unset.
custom-validity string Makes it invalid with this message, as setCustomValidity() does, and shows the message at once rather than once validity is reported, for an error the page already knows about, such as one from a server. Removing it, or setting it to an empty string, makes it valid again, unless something else makes it invalid.
Properties
Name Type Description
addedLabel (count: number) => string What screenreaders are told when files are dropped, from how many were added. "1 file added" and so on in English when unset.
notAcceptedLabel (count: number) => string What screenreaders are told when dropped files are left out for not matching accept, from how many were. "1 file isn't an accepted type" and so on in English when unset.
files Read-only FileList | null The files chosen or dropped, as a native file input's files.
form Read-only HTMLFormElement | null The form it belongs to, or null.
labels Read-only NodeList The <label> elements associated with it, as a native control's labels: each <label for> that names its id, and a <label> around it.
validationMessage Read-only string What's wrong, as the validity message says it: the message given to setCustomValidity() or setValidity(), or else the browser's own. Empty while it's valid.
validity Read-only ValidityState Its ValidityState, as a native control's.
willValidate Read-only boolean Whether its validity is checked when its form submits. It isn't while it's disabled or read-only.
Methods
Signature Description
checkValidity(): boolean Whether its value is valid. Dispatches "invalid" when it isn't, as a native control's does.
click(): void Clicks it, as a native element's click() does.
focus(options?: FocusOptions): void Focuses it, or the part of it that takes focus.
reportValidity(): boolean Whether its value is valid. When it isn't, dispatches "invalid" and shows the validity message, as a native control's does.
resetValidityFeedback(): void Clears the validity feedback without changing validity.
setCustomValidity(message: string): void Makes it invalid with a message of your own, or valid again with an empty one, as a native control's does.
setValidity(flags?: ValidityStateFlags, message?: string): void Sets its validity and message, as ElementInternals.setValidity() does, for checks of your own beyond setCustomValidity().
Events
Name Type Description
input Event As the user changes its value, as a native control's does. Setting it from code doesn't dispatch it.
change Event When the user changes its value, as a native control's does. Setting it from code doesn't dispatch it.
invalid Event When a check finds its value invalid, as a native control's does. Cancel it to leave the validity message unshown, after a blur, a submit or reportValidity(), and focus where it is.
Slots
Name Type Description
description Element | string Text that describes it, such as a hint or what the validity message means. It's its accessible description.
validity-message Element | string Shown in place of the validity message's text while it's invalid and the message shows, for wording of your own, a translation, or a link. It's part of its accessible description, and validationMessage stays the browser's or setCustomValidity()'s.
CSS parts
Name Description
description Text about the field, and its validity message when it has one
input The input
label The label
validity-message The validity message, which says why the value is invalid
CSS states
Name Description
:state(disabled) While it's disabled.
:state(drag-over) While the user drags files over it.
:state(error) While it's invalid and its validity message shows, which is once its validity is reported, as when its form is submitted.
:state(required) While it's required, for styles such as an asterisk.

Copy and own it

<slab-styled-file-drop> isn't in the package. It's an example — copy it into your project and change whatever you want. Keyboard, focus, ARIA, forms, and events all come from the headless element, and the styles only reach in through ::part() and :state(), same as yours would.

ReactLitVueSvelteEmber

The same styles, written from outside the element, so there's nothing to subclass. The CSS styles every <slab-file-drop> on the page. Import tokens.css, the colors and fonts every styled example shares, once, wherever your global styles go.

Each component registers its headless element and imports its CSS. Use it like the element: its props are the element's attributes and properties.

FileDrop.jsx
import 'slab-elements/file-drop.js';
import './file-drop.css';

export function FileDrop(props) {
  return <slab-file-drop {...props} />;
}
file-drop.css
slab-file-drop {
  color: var(--ink);
  display: grid;
  font-family: var(--font-body);
}

slab-file-drop::part(label) {
  font-family: var(--font-display);
  font-size: 1.0625rem;
  font-weight: 600;
  margin-block-end: 0.375rem;
}

slab-file-drop:state(required)::part(label)::after {
  color: var(--ember-deep);
  content: ' *' / '';
}

slab-file-drop::part(input),
slab-file-drop::part(textarea) {
  background-color: var(--paper);
  block-size: 3rem;
  border: var(--border);
  border-radius: 0;
  box-sizing: border-box;
  color: inherit;
  font: inherit;
  /* A fixed height, shared with Select, so fields line up in a row. */
  padding: 0 0.75rem;
  transition:
    background-color 100ms,
    border-color 100ms,
    box-shadow 100ms,
    translate 100ms;
}

slab-file-drop::part(input)::placeholder,
slab-file-drop::part(textarea)::placeholder {
  color: var(--ash);
}

/*
  The outline is transparent rather than gone, so it still shows in forced
  colors, where box shadows don't.
*/
slab-file-drop::part(input):focus-visible,
slab-file-drop::part(textarea):focus-visible {
  box-shadow: 4px 4px 0 var(--ember);
  outline: 2px solid transparent;
  translate: -2px -2px;
}

slab-file-drop::part(input):disabled,
slab-file-drop::part(textarea):disabled {
  background-color: var(--chalk);
  border-style: dashed;
  color: var(--ash);
  cursor: not-allowed;
}

slab-file-drop::part(textarea) {
  block-size: auto;
  min-block-size: 7rem;
  padding: 0.625rem 0.75rem;
  resize: vertical;
}

slab-file-drop:state(readonly)::part(input),
slab-file-drop:state(readonly)::part(textarea) {
  background-color: var(--chalk);
}

slab-file-drop:state(error)::part(input),
slab-file-drop:state(error)::part(textarea) {
  border-color: var(--ember-deep);
}

/*
  Spaced by what's in it rather than by a gap, so a description with
  nothing in it takes no room, and a control beside the field lines up
  with its bottom edge.
*/
slab-file-drop::part(description) {
  color: var(--ash);
  display: grid;
  font-size: 0.875rem;
}

slab-file-drop > [slot='description'] {
  margin-block-start: 0.375rem;
}

slab-file-drop::part(validity-message) {
  color: var(--ember-deep);
  font-weight: 600;
  margin-block-start: 0.375rem;
}

slab-file-drop::part(validity-message)::before {
  content: '■ ' / '';
}

@media (prefers-reduced-motion: reduce) {
  slab-file-drop::part(input),
  slab-file-drop::part(textarea) {
    transition: none;
  }
}

slab-file-drop::part(input) {
  background-color: var(--paper);
  block-size: auto;
  border: 2px dashed var(--ink);
  cursor: pointer;
  padding: 1.5rem;
  transition:
    background-color 100ms,
    border-color 100ms;
}

slab-file-drop::part(input)::file-selector-button {
  background-color: var(--ink);
  border: 0;
  box-shadow: 3px 3px 0 var(--ember);
  color: var(--paper);
  cursor: pointer;
  font-family: var(--font-display);
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  margin-inline-end: 1rem;
  padding: 0.5rem 1rem;
  text-transform: uppercase;
}

slab-file-drop:state(drag-over)::part(input) {
  background-color: var(--chalk);
  border-color: var(--ember);
  border-style: solid;
}

@media (prefers-reduced-motion: reduce) {
  slab-file-drop::part(input) {
    transition: none;
  }
}
tokens.css
:root {
  /* Secondary text. 6.8:1 and 6.9:1 on paper. */
  --ash: var(--slab-styled-ash, light-dark(#5e5a55, #a8a19a));
  --border: 2px solid var(--ink);

  /* Behind disabled and read-only controls, and hovered rows. */
  --chalk: var(--slab-styled-chalk, light-dark(#f4f1ec, #2b2926));

  /*
    The logo's orange, brighter in the dark. 4.25:1 and 5.2:1 on paper is
    enough for borders, fills and large text, but not always for small text,
    which takes "--ember-deep".
  */
  --ember: var(--slab-styled-ember, light-dark(#d9492a, #ec5f3b));

  /*
    Orange for small text on paper, and for paper text on it. 5.7:1 and
    7.4:1.
  */
  --ember-deep: var(--slab-styled-ember-deep, light-dark(#b3381a, #ff8566));
  --font-body: var(
    --slab-styled-font-body,
    'IBM Plex Sans',
    system-ui,
    sans-serif
  );
  --font-display: var(
    --slab-styled-font-display,
    'Zilla Slab',
    rockwell,
    'Roboto Slab',
    serif
  );
  --font-mono: var(
    --slab-styled-font-mono,
    'IBM Plex Mono',
    ui-monospace,
    monospace
  );
  --ink: var(--slab-styled-ink, light-dark(#1c1c1c, #f4f1ec));
  --paper: var(--slab-styled-paper, light-dark(#fff, #1a1918));

  /* The hard, offset shadow a raised surface casts. */
  --shadow: 4px 4px 0 var(--ink);
}

/*
  Forced colors, such as Windows' contrast themes, replace every color that
  isn't a system color, so ember fills and paper marks all become the same
  background, and a checked Checkbox looks like an unchecked one. The palette
  becomes the user's system colors instead, which are kept. Ember is the
  highlight, the color of what's selected, and ember-deep, being for text and
  for paper text on it, is the text color.
*/
@media (forced-colors: active) {
  :host {
    --ash: GrayText;
    --chalk: Canvas;
    --ember: Highlight;
    --ember-deep: CanvasText;
    --ink: CanvasText;
    --paper: Canvas;
  }
}

Under the hood, it's just the headless element, subclassed, with styles set. That's it. To use it, copy these files, swap the tag in @customElement() for one of your own, and import it. tokens.styles.ts holds the colors and fonts every styled example shares, so you only need it once.

file-drop.ts
import { customElement } from 'lit/decorators.js';
import FileDrop from 'slab-elements/file-drop.js';
import textInput from './text-input.styles.js';
import styles from './file-drop.styles.js';
import tokens from './tokens.styles.js';

declare global {
  interface HTMLElementTagNameMap {
    'slab-styled-file-drop': StyledFileDrop;
  }
}

/**
 * File Drop, styled: a dashed drop zone with a button for the picker, which
 * turns ember while files are dragged over it.
 */
@customElement('slab-styled-file-drop')
export default class StyledFileDrop extends FileDrop {
  static override styles = [tokens, textInput, styles];
}
text-input.styles.ts
import { css } from 'lit';

/*
  The look shared by everything typed into: Text Field, Password Field,
  Search Field, Textarea, Number, Date Field, Time Field, Combobox and Tags
  Input, whose fields are "::part(input)", or "::part(textarea)" for Textarea.
  File Drop starts from it too, for its label and description.
*/
export default css`
  :host {
    color: var(--ink);
    display: grid;
    font-family: var(--font-body);
  }

  [part~='label'] {
    font-family: var(--font-display);
    font-size: 1.0625rem;
    font-weight: 600;
    margin-block-end: 0.375rem;
  }

  :host(:state(required)) [part~='label']::after {
    color: var(--ember-deep);
    content: ' *' / '';
  }

  [part~='input'],
  [part~='textarea'] {
    background-color: var(--paper);
    block-size: 3rem;
    border: var(--border);
    border-radius: 0;
    box-sizing: border-box;
    color: inherit;
    font: inherit;

    /* A fixed height, shared with Select, so fields line up in a row. */
    padding: 0 0.75rem;
    transition:
      background-color 100ms,
      border-color 100ms,
      box-shadow 100ms,
      translate 100ms;

    &::placeholder {
      color: var(--ash);
    }

    /*
      The outline is transparent rather than gone, so it still shows in forced
      colors, where box shadows don't.
    */
    &:focus-visible {
      box-shadow: 4px 4px 0 var(--ember);
      outline: 2px solid transparent;
      translate: -2px -2px;
    }

    &:disabled {
      background-color: var(--chalk);
      border-style: dashed;
      color: var(--ash);
      cursor: not-allowed;
    }
  }

  [part~='textarea'] {
    block-size: auto;
    min-block-size: 7rem;
    padding: 0.625rem 0.75rem;
    resize: vertical;
  }

  :host(:state(readonly)) [part~='input'],
  :host(:state(readonly)) [part~='textarea'] {
    background-color: var(--chalk);
  }

  :host(:state(error)) [part~='input'],
  :host(:state(error)) [part~='textarea'] {
    border-color: var(--ember-deep);
  }

  /*
    Spaced by what's in it rather than by a gap, so a description with
    nothing in it takes no room, and a control beside the field lines up
    with its bottom edge.
  */
  [part~='description'] {
    color: var(--ash);
    display: grid;
    font-size: 0.875rem;
  }

  ::slotted([slot='description']) {
    margin-block-start: 0.375rem;
  }

  [part~='validity-message'] {
    color: var(--ember-deep);
    font-weight: 600;
    margin-block-start: 0.375rem;

    &::before {
      content: '■ ' / '';
    }
  }

  @media (prefers-reduced-motion: reduce) {
    [part~='input'],
    [part~='textarea'] {
      transition: none;
    }
  }
`;
file-drop.styles.ts
import { css } from 'lit';

/*
  Text Field's label and description, with the file input as a drop zone
  rather than a field. The input is the zone, so a drop anywhere on it lands,
  and its picker button is styled as a Button.
*/
export default css`
  [part~='input'] {
    background-color: var(--paper);
    block-size: auto;
    border: 2px dashed var(--ink);
    cursor: pointer;
    padding: 1.5rem;
    transition:
      background-color 100ms,
      border-color 100ms;

    &::file-selector-button {
      background-color: var(--ink);
      border: 0;
      box-shadow: 3px 3px 0 var(--ember);
      color: var(--paper);
      cursor: pointer;
      font-family: var(--font-display);
      font-size: 0.9375rem;
      font-weight: 600;
      letter-spacing: 0.04em;
      margin-inline-end: 1rem;
      padding: 0.5rem 1rem;
      text-transform: uppercase;
    }
  }

  :host(:state(drag-over)) [part~='input'] {
    background-color: var(--chalk);
    border-color: var(--ember);
    border-style: solid;
  }

  @media (prefers-reduced-motion: reduce) {
    [part~='input'] {
      transition: none;
    }
  }
`;
tokens.styles.ts
import { css } from 'lit';

/*
  The styled components' palette and type, taken from the logo: ink for the
  courses, ember for the base, paper behind them.

  Each is a short alias for a "--slab-styled-*" property, with the default as
  its fallback. Retheming is "--slab-styled-ember" and the rest on ":root",
  which every shadow root inherits. Were the defaults declared under those
  names here instead, each host's own declaration would shadow the page's.

  Each default is "light-dark()", so the components follow the page's
  "color-scheme": "dark" for dark, "light" for light, and "light dark" to
  follow the operating system. Ink and paper trade places in the dark, so
  ink is always the text and paper always what's behind it. Contrast is given
  as light, then dark.
*/
export default css`
  :host {
    /* Secondary text. 6.8:1 and 6.9:1 on paper. */
    --ash: var(--slab-styled-ash, light-dark(#5e5a55, #a8a19a));
    --border: 2px solid var(--ink);

    /* Behind disabled and read-only controls, and hovered rows. */
    --chalk: var(--slab-styled-chalk, light-dark(#f4f1ec, #2b2926));

    /*
      The logo's orange, brighter in the dark. 4.25:1 and 5.2:1 on paper is
      enough for borders, fills and large text, but not always for small text,
      which takes "--ember-deep".
    */
    --ember: var(--slab-styled-ember, light-dark(#d9492a, #ec5f3b));

    /*
      Orange for small text on paper, and for paper text on it. 5.7:1 and
      7.4:1.
    */
    --ember-deep: var(--slab-styled-ember-deep, light-dark(#b3381a, #ff8566));
    --font-body: var(
      --slab-styled-font-body,
      'IBM Plex Sans',
      system-ui,
      sans-serif
    );
    --font-display: var(
      --slab-styled-font-display,
      'Zilla Slab',
      rockwell,
      'Roboto Slab',
      serif
    );
    --font-mono: var(
      --slab-styled-font-mono,
      'IBM Plex Mono',
      ui-monospace,
      monospace
    );
    --ink: var(--slab-styled-ink, light-dark(#1c1c1c, #f4f1ec));
    --paper: var(--slab-styled-paper, light-dark(#fff, #1a1918));

    /* The hard, offset shadow a raised surface casts. */
    --shadow: 4px 4px 0 var(--ink);
  }

  /*
    Forced colors, such as Windows' contrast themes, replace every color that
    isn't a system color, so ember fills and paper marks all become the same
    background, and a checked Checkbox looks like an unchecked one. The palette
    becomes the user's system colors instead, which are kept. Ember is the
    highlight, the color of what's selected, and ember-deep, being for text and
    for paper text on it, is the text color.
  */
  @media (forced-colors: active) {
    :host {
      --ash: GrayText;
      --chalk: Canvas;
      --ember: Highlight;
      --ember-deep: CanvasText;
      --ink: CanvasText;
      --paper: Canvas;
    }
  }
`;

The same styles, written from outside the element, so there's nothing to subclass. The CSS styles every <slab-file-drop> on the page. Import tokens.css, the colors and fonts every styled example shares, once, wherever your global styles go.

Each component registers its headless element and imports its CSS. Use it like the element: its props are the element's attributes and properties.

FileDrop.vue
<script setup>
import 'slab-elements/file-drop.js';
import './file-drop.css';
</script>

<template>
  <slab-file-drop><slot /></slab-file-drop>
</template>
file-drop.css
slab-file-drop {
  color: var(--ink);
  display: grid;
  font-family: var(--font-body);
}

slab-file-drop::part(label) {
  font-family: var(--font-display);
  font-size: 1.0625rem;
  font-weight: 600;
  margin-block-end: 0.375rem;
}

slab-file-drop:state(required)::part(label)::after {
  color: var(--ember-deep);
  content: ' *' / '';
}

slab-file-drop::part(input),
slab-file-drop::part(textarea) {
  background-color: var(--paper);
  block-size: 3rem;
  border: var(--border);
  border-radius: 0;
  box-sizing: border-box;
  color: inherit;
  font: inherit;
  /* A fixed height, shared with Select, so fields line up in a row. */
  padding: 0 0.75rem;
  transition:
    background-color 100ms,
    border-color 100ms,
    box-shadow 100ms,
    translate 100ms;
}

slab-file-drop::part(input)::placeholder,
slab-file-drop::part(textarea)::placeholder {
  color: var(--ash);
}

/*
  The outline is transparent rather than gone, so it still shows in forced
  colors, where box shadows don't.
*/
slab-file-drop::part(input):focus-visible,
slab-file-drop::part(textarea):focus-visible {
  box-shadow: 4px 4px 0 var(--ember);
  outline: 2px solid transparent;
  translate: -2px -2px;
}

slab-file-drop::part(input):disabled,
slab-file-drop::part(textarea):disabled {
  background-color: var(--chalk);
  border-style: dashed;
  color: var(--ash);
  cursor: not-allowed;
}

slab-file-drop::part(textarea) {
  block-size: auto;
  min-block-size: 7rem;
  padding: 0.625rem 0.75rem;
  resize: vertical;
}

slab-file-drop:state(readonly)::part(input),
slab-file-drop:state(readonly)::part(textarea) {
  background-color: var(--chalk);
}

slab-file-drop:state(error)::part(input),
slab-file-drop:state(error)::part(textarea) {
  border-color: var(--ember-deep);
}

/*
  Spaced by what's in it rather than by a gap, so a description with
  nothing in it takes no room, and a control beside the field lines up
  with its bottom edge.
*/
slab-file-drop::part(description) {
  color: var(--ash);
  display: grid;
  font-size: 0.875rem;
}

slab-file-drop > [slot='description'] {
  margin-block-start: 0.375rem;
}

slab-file-drop::part(validity-message) {
  color: var(--ember-deep);
  font-weight: 600;
  margin-block-start: 0.375rem;
}

slab-file-drop::part(validity-message)::before {
  content: '■ ' / '';
}

@media (prefers-reduced-motion: reduce) {
  slab-file-drop::part(input),
  slab-file-drop::part(textarea) {
    transition: none;
  }
}

slab-file-drop::part(input) {
  background-color: var(--paper);
  block-size: auto;
  border: 2px dashed var(--ink);
  cursor: pointer;
  padding: 1.5rem;
  transition:
    background-color 100ms,
    border-color 100ms;
}

slab-file-drop::part(input)::file-selector-button {
  background-color: var(--ink);
  border: 0;
  box-shadow: 3px 3px 0 var(--ember);
  color: var(--paper);
  cursor: pointer;
  font-family: var(--font-display);
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  margin-inline-end: 1rem;
  padding: 0.5rem 1rem;
  text-transform: uppercase;
}

slab-file-drop:state(drag-over)::part(input) {
  background-color: var(--chalk);
  border-color: var(--ember);
  border-style: solid;
}

@media (prefers-reduced-motion: reduce) {
  slab-file-drop::part(input) {
    transition: none;
  }
}
tokens.css
:root {
  /* Secondary text. 6.8:1 and 6.9:1 on paper. */
  --ash: var(--slab-styled-ash, light-dark(#5e5a55, #a8a19a));
  --border: 2px solid var(--ink);

  /* Behind disabled and read-only controls, and hovered rows. */
  --chalk: var(--slab-styled-chalk, light-dark(#f4f1ec, #2b2926));

  /*
    The logo's orange, brighter in the dark. 4.25:1 and 5.2:1 on paper is
    enough for borders, fills and large text, but not always for small text,
    which takes "--ember-deep".
  */
  --ember: var(--slab-styled-ember, light-dark(#d9492a, #ec5f3b));

  /*
    Orange for small text on paper, and for paper text on it. 5.7:1 and
    7.4:1.
  */
  --ember-deep: var(--slab-styled-ember-deep, light-dark(#b3381a, #ff8566));
  --font-body: var(
    --slab-styled-font-body,
    'IBM Plex Sans',
    system-ui,
    sans-serif
  );
  --font-display: var(
    --slab-styled-font-display,
    'Zilla Slab',
    rockwell,
    'Roboto Slab',
    serif
  );
  --font-mono: var(
    --slab-styled-font-mono,
    'IBM Plex Mono',
    ui-monospace,
    monospace
  );
  --ink: var(--slab-styled-ink, light-dark(#1c1c1c, #f4f1ec));
  --paper: var(--slab-styled-paper, light-dark(#fff, #1a1918));

  /* The hard, offset shadow a raised surface casts. */
  --shadow: 4px 4px 0 var(--ink);
}

/*
  Forced colors, such as Windows' contrast themes, replace every color that
  isn't a system color, so ember fills and paper marks all become the same
  background, and a checked Checkbox looks like an unchecked one. The palette
  becomes the user's system colors instead, which are kept. Ember is the
  highlight, the color of what's selected, and ember-deep, being for text and
  for paper text on it, is the text color.
*/
@media (forced-colors: active) {
  :host {
    --ash: GrayText;
    --chalk: Canvas;
    --ember: Highlight;
    --ember-deep: CanvasText;
    --ink: CanvasText;
    --paper: Canvas;
  }
}

The same styles, written from outside the element, so there's nothing to subclass. The CSS styles every <slab-file-drop> on the page. Import tokens.css, the colors and fonts every styled example shares, once, wherever your global styles go.

Import file-drop.js once, such as in your root layout, and use <slab-file-drop> as is. A Svelte component around it would take slot="…" content as its own slot and drop it.

file-drop.js
import 'slab-elements/file-drop.js';
import './file-drop.css';
file-drop.css
slab-file-drop {
  color: var(--ink);
  display: grid;
  font-family: var(--font-body);
}

slab-file-drop::part(label) {
  font-family: var(--font-display);
  font-size: 1.0625rem;
  font-weight: 600;
  margin-block-end: 0.375rem;
}

slab-file-drop:state(required)::part(label)::after {
  color: var(--ember-deep);
  content: ' *' / '';
}

slab-file-drop::part(input),
slab-file-drop::part(textarea) {
  background-color: var(--paper);
  block-size: 3rem;
  border: var(--border);
  border-radius: 0;
  box-sizing: border-box;
  color: inherit;
  font: inherit;
  /* A fixed height, shared with Select, so fields line up in a row. */
  padding: 0 0.75rem;
  transition:
    background-color 100ms,
    border-color 100ms,
    box-shadow 100ms,
    translate 100ms;
}

slab-file-drop::part(input)::placeholder,
slab-file-drop::part(textarea)::placeholder {
  color: var(--ash);
}

/*
  The outline is transparent rather than gone, so it still shows in forced
  colors, where box shadows don't.
*/
slab-file-drop::part(input):focus-visible,
slab-file-drop::part(textarea):focus-visible {
  box-shadow: 4px 4px 0 var(--ember);
  outline: 2px solid transparent;
  translate: -2px -2px;
}

slab-file-drop::part(input):disabled,
slab-file-drop::part(textarea):disabled {
  background-color: var(--chalk);
  border-style: dashed;
  color: var(--ash);
  cursor: not-allowed;
}

slab-file-drop::part(textarea) {
  block-size: auto;
  min-block-size: 7rem;
  padding: 0.625rem 0.75rem;
  resize: vertical;
}

slab-file-drop:state(readonly)::part(input),
slab-file-drop:state(readonly)::part(textarea) {
  background-color: var(--chalk);
}

slab-file-drop:state(error)::part(input),
slab-file-drop:state(error)::part(textarea) {
  border-color: var(--ember-deep);
}

/*
  Spaced by what's in it rather than by a gap, so a description with
  nothing in it takes no room, and a control beside the field lines up
  with its bottom edge.
*/
slab-file-drop::part(description) {
  color: var(--ash);
  display: grid;
  font-size: 0.875rem;
}

slab-file-drop > [slot='description'] {
  margin-block-start: 0.375rem;
}

slab-file-drop::part(validity-message) {
  color: var(--ember-deep);
  font-weight: 600;
  margin-block-start: 0.375rem;
}

slab-file-drop::part(validity-message)::before {
  content: '■ ' / '';
}

@media (prefers-reduced-motion: reduce) {
  slab-file-drop::part(input),
  slab-file-drop::part(textarea) {
    transition: none;
  }
}

slab-file-drop::part(input) {
  background-color: var(--paper);
  block-size: auto;
  border: 2px dashed var(--ink);
  cursor: pointer;
  padding: 1.5rem;
  transition:
    background-color 100ms,
    border-color 100ms;
}

slab-file-drop::part(input)::file-selector-button {
  background-color: var(--ink);
  border: 0;
  box-shadow: 3px 3px 0 var(--ember);
  color: var(--paper);
  cursor: pointer;
  font-family: var(--font-display);
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  margin-inline-end: 1rem;
  padding: 0.5rem 1rem;
  text-transform: uppercase;
}

slab-file-drop:state(drag-over)::part(input) {
  background-color: var(--chalk);
  border-color: var(--ember);
  border-style: solid;
}

@media (prefers-reduced-motion: reduce) {
  slab-file-drop::part(input) {
    transition: none;
  }
}
tokens.css
:root {
  /* Secondary text. 6.8:1 and 6.9:1 on paper. */
  --ash: var(--slab-styled-ash, light-dark(#5e5a55, #a8a19a));
  --border: 2px solid var(--ink);

  /* Behind disabled and read-only controls, and hovered rows. */
  --chalk: var(--slab-styled-chalk, light-dark(#f4f1ec, #2b2926));

  /*
    The logo's orange, brighter in the dark. 4.25:1 and 5.2:1 on paper is
    enough for borders, fills and large text, but not always for small text,
    which takes "--ember-deep".
  */
  --ember: var(--slab-styled-ember, light-dark(#d9492a, #ec5f3b));

  /*
    Orange for small text on paper, and for paper text on it. 5.7:1 and
    7.4:1.
  */
  --ember-deep: var(--slab-styled-ember-deep, light-dark(#b3381a, #ff8566));
  --font-body: var(
    --slab-styled-font-body,
    'IBM Plex Sans',
    system-ui,
    sans-serif
  );
  --font-display: var(
    --slab-styled-font-display,
    'Zilla Slab',
    rockwell,
    'Roboto Slab',
    serif
  );
  --font-mono: var(
    --slab-styled-font-mono,
    'IBM Plex Mono',
    ui-monospace,
    monospace
  );
  --ink: var(--slab-styled-ink, light-dark(#1c1c1c, #f4f1ec));
  --paper: var(--slab-styled-paper, light-dark(#fff, #1a1918));

  /* The hard, offset shadow a raised surface casts. */
  --shadow: 4px 4px 0 var(--ink);
}

/*
  Forced colors, such as Windows' contrast themes, replace every color that
  isn't a system color, so ember fills and paper marks all become the same
  background, and a checked Checkbox looks like an unchecked one. The palette
  becomes the user's system colors instead, which are kept. Ember is the
  highlight, the color of what's selected, and ember-deep, being for text and
  for paper text on it, is the text color.
*/
@media (forced-colors: active) {
  :host {
    --ash: GrayText;
    --chalk: Canvas;
    --ember: Highlight;
    --ember-deep: CanvasText;
    --ink: CanvasText;
    --paper: Canvas;
  }
}

The same styles, written from outside the element, so there's nothing to subclass. The CSS styles every <slab-file-drop> on the page. Import tokens.css, the colors and fonts every styled example shares, once, wherever your global styles go.

Each component registers its headless element and imports its CSS. Use it like the element: its attributes and its content go to the element.

FileDrop.gjs
import 'slab-elements/file-drop.js';
import './file-drop.css';

export const FileDrop = <template>
  <slab-file-drop ...attributes>{{yield}}</slab-file-drop>
</template>;
file-drop.css
slab-file-drop {
  color: var(--ink);
  display: grid;
  font-family: var(--font-body);
}

slab-file-drop::part(label) {
  font-family: var(--font-display);
  font-size: 1.0625rem;
  font-weight: 600;
  margin-block-end: 0.375rem;
}

slab-file-drop:state(required)::part(label)::after {
  color: var(--ember-deep);
  content: ' *' / '';
}

slab-file-drop::part(input),
slab-file-drop::part(textarea) {
  background-color: var(--paper);
  block-size: 3rem;
  border: var(--border);
  border-radius: 0;
  box-sizing: border-box;
  color: inherit;
  font: inherit;
  /* A fixed height, shared with Select, so fields line up in a row. */
  padding: 0 0.75rem;
  transition:
    background-color 100ms,
    border-color 100ms,
    box-shadow 100ms,
    translate 100ms;
}

slab-file-drop::part(input)::placeholder,
slab-file-drop::part(textarea)::placeholder {
  color: var(--ash);
}

/*
  The outline is transparent rather than gone, so it still shows in forced
  colors, where box shadows don't.
*/
slab-file-drop::part(input):focus-visible,
slab-file-drop::part(textarea):focus-visible {
  box-shadow: 4px 4px 0 var(--ember);
  outline: 2px solid transparent;
  translate: -2px -2px;
}

slab-file-drop::part(input):disabled,
slab-file-drop::part(textarea):disabled {
  background-color: var(--chalk);
  border-style: dashed;
  color: var(--ash);
  cursor: not-allowed;
}

slab-file-drop::part(textarea) {
  block-size: auto;
  min-block-size: 7rem;
  padding: 0.625rem 0.75rem;
  resize: vertical;
}

slab-file-drop:state(readonly)::part(input),
slab-file-drop:state(readonly)::part(textarea) {
  background-color: var(--chalk);
}

slab-file-drop:state(error)::part(input),
slab-file-drop:state(error)::part(textarea) {
  border-color: var(--ember-deep);
}

/*
  Spaced by what's in it rather than by a gap, so a description with
  nothing in it takes no room, and a control beside the field lines up
  with its bottom edge.
*/
slab-file-drop::part(description) {
  color: var(--ash);
  display: grid;
  font-size: 0.875rem;
}

slab-file-drop > [slot='description'] {
  margin-block-start: 0.375rem;
}

slab-file-drop::part(validity-message) {
  color: var(--ember-deep);
  font-weight: 600;
  margin-block-start: 0.375rem;
}

slab-file-drop::part(validity-message)::before {
  content: '■ ' / '';
}

@media (prefers-reduced-motion: reduce) {
  slab-file-drop::part(input),
  slab-file-drop::part(textarea) {
    transition: none;
  }
}

slab-file-drop::part(input) {
  background-color: var(--paper);
  block-size: auto;
  border: 2px dashed var(--ink);
  cursor: pointer;
  padding: 1.5rem;
  transition:
    background-color 100ms,
    border-color 100ms;
}

slab-file-drop::part(input)::file-selector-button {
  background-color: var(--ink);
  border: 0;
  box-shadow: 3px 3px 0 var(--ember);
  color: var(--paper);
  cursor: pointer;
  font-family: var(--font-display);
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  margin-inline-end: 1rem;
  padding: 0.5rem 1rem;
  text-transform: uppercase;
}

slab-file-drop:state(drag-over)::part(input) {
  background-color: var(--chalk);
  border-color: var(--ember);
  border-style: solid;
}

@media (prefers-reduced-motion: reduce) {
  slab-file-drop::part(input) {
    transition: none;
  }
}
tokens.css
:root {
  /* Secondary text. 6.8:1 and 6.9:1 on paper. */
  --ash: var(--slab-styled-ash, light-dark(#5e5a55, #a8a19a));
  --border: 2px solid var(--ink);

  /* Behind disabled and read-only controls, and hovered rows. */
  --chalk: var(--slab-styled-chalk, light-dark(#f4f1ec, #2b2926));

  /*
    The logo's orange, brighter in the dark. 4.25:1 and 5.2:1 on paper is
    enough for borders, fills and large text, but not always for small text,
    which takes "--ember-deep".
  */
  --ember: var(--slab-styled-ember, light-dark(#d9492a, #ec5f3b));

  /*
    Orange for small text on paper, and for paper text on it. 5.7:1 and
    7.4:1.
  */
  --ember-deep: var(--slab-styled-ember-deep, light-dark(#b3381a, #ff8566));
  --font-body: var(
    --slab-styled-font-body,
    'IBM Plex Sans',
    system-ui,
    sans-serif
  );
  --font-display: var(
    --slab-styled-font-display,
    'Zilla Slab',
    rockwell,
    'Roboto Slab',
    serif
  );
  --font-mono: var(
    --slab-styled-font-mono,
    'IBM Plex Mono',
    ui-monospace,
    monospace
  );
  --ink: var(--slab-styled-ink, light-dark(#1c1c1c, #f4f1ec));
  --paper: var(--slab-styled-paper, light-dark(#fff, #1a1918));

  /* The hard, offset shadow a raised surface casts. */
  --shadow: 4px 4px 0 var(--ink);
}

/*
  Forced colors, such as Windows' contrast themes, replace every color that
  isn't a system color, so ember fills and paper marks all become the same
  background, and a checked Checkbox looks like an unchecked one. The palette
  becomes the user's system colors instead, which are kept. Ember is the
  highlight, the color of what's selected, and ember-deep, being for text and
  for paper text on it, is the text color.
*/
@media (forced-colors: active) {
  :host {
    --ash: GrayText;
    --chalk: Canvas;
    --ember: Highlight;
    --ember-deep: CanvasText;
    --ink: CanvasText;
    --paper: Canvas;
  }
}