Rost

← All components

component

Dropzone

A place to drop a file, with a button for when dragging isn't handy: an arrow, what to drop, what's allowed, and Choose a file.

In code Contract: review Guidance: proposed Contract on GitHub Figma 746:132 As markdown
Drop a bank statement herePDF or CSV, up to 10 MB
Not over · Not error
Drop a bank statement herePDF or CSV, up to 10 MB
Over · Not error
Drop a bank statement hereThat's a PNG. Try a PDF or CSV.
Not over · Error

Install

npx github:Runceanu/rost add dropzone

It lands in src/rost/dropzone/, with what it needs and its contract. Install has the rest.

When to use

  • Bringing in a document

    A bank statement to import, a receipt to attach. Say in the help which kinds of file work and how big.

When not to use

  • Dragging as the only way

    Not everyone can drag. The button stays, always.

  • Showing the upload

    What happens after the drop, the progress and the file's name, belongs under it, in a Progress or a ListItem.

    Use Progress

Behaviour

Dragging a file over it turns its edge green. Dropping or choosing hands the files to onFiles. With error the edge and the help turn red, and the help says what to fix.

Accessibility

  • Element

    A <div> with a real file input and a real button inside. The drop is a shortcut for the button, never the only way.

  • Name

    The button's words. The help is tied to the button with aria-describedby, so it's read with them.

  • Colour

    The idle edge is 4.3:1 on the dark page, the error help 6.9:1.

Content

The title says what to drop, the help what's allowed: PDF or CSV, up to 10 MB.

Props

PropTypeValuesDefault
title slot
help slot
action string Choose a file
accept string
multiple boolean false
error boolean false
over boolean false

Values

Straight from the contract. Each value sits next to its token, because six tokens here all come out as #3a3a3a and the colour alone can't tell you which one is right.

Never changes

root

  • gap 12px spacing/gap/small-medium
  • padding 24px spacing/gap/large
  • border-radius 12px spacing/radius/medium

displayflex · flex-directioncolumn · align-itemscenter · text-aligncenter · positionrelative · outline-stylesolid

icon

  • color #d3d9d5 dropzone/icon

displayflex

words

  • gap 2px spacing/gap/3xsmall

displayflex · flex-directioncolumn

title

  • font-family 'General Sans Variable' font-family/base
  • font-weight 500 typography/paragraph/font-weight/medium
  • font-size 14px typography/paragraph/font-size
  • line-height 20px typography/paragraph/line-height
  • letter-spacing 0px typography/paragraph/letter-spacing
  • color #ededed dropzone/title

help

  • font-family 'General Sans Variable' font-family/base
  • font-weight 400 typography/label/font-weight/regular
  • font-size 12px typography/label/font-size
  • line-height 14px typography/label/line-height
  • letter-spacing 0px typography/label/letter-spacing

input

positionabsolute · width1px · height1px · opacity0 · pointer-eventsnone

Changes by variant

3 variants. Each table is what one thing changes with: a column per over, a row per property. Where every row starts with the same token path, it's written once, under the property.

Follows over

PropertyNot overOver
root.outline-offsetcalc(-1 * …) spacing-outline-small spacing-outline-medium
root.outline-widthspacing/outline/… small 1px medium 2px

Follows error

PropertyNot errorError
help.colordropzone/… help #999999 error/help #f2705f

Follows over and error

Not error

PropertyNot overOver
root.outline-colordropzone/… idle/edge #747573 over/edge #00d669

Error

PropertyNot overOver
root.outline-color dropzone/error/edge #f2705f·

Only in some variants

These don't change: they're just set in some variants and not others.

Over

  • root.background #171717 dropzone/over/background