Skip to main content

What are you looking for?

Try searching for…

Components

File upload

File upload is a form element used to upload files.

File upload is under development. If you have feedback or suggestions, please report them on Github or in Slack.

Press Enter to start editing
Unable to parse html
const PreviewEn = () => (
  <Field>
    <Label>Upload profile picture</Label>
    <Field.Description>
      File must be in csv format and less than 2MB
    </Field.Description>
    <EXPERIMENTAL_FileUpload>
      <Field.Description>Drop file here</Field.Description>
      <Button asChild data-variant='secondary'>
        <span>Upload file</span>
      </Button>
      <input type='file' />
    </EXPERIMENTAL_FileUpload>
  </Field>
);

render(<PreviewEn />)

Usage

Place File upload inside a field with a label so the upload area gets an accessible label.

In plain HTML, use the class ds-file-upload on an element that contains an <input type="file">. The input is placed on top of the whole area so the entire surface becomes clickable.

To make the area read-only, set readonly on the input. The component then automatically switches to a neutral color scale and disables interaction.

CSS variables and data attributes

File upload uses its own CSS variables to control things like background, border, icon and spacing. These can be overridden on .ds-file-upload.

CSS Variables
NameValue
--dsc-file-upload-backgroundvar(--ds-color-surface-default)
--dsc-file-upload-background--hovervar(--ds-color-surface-tinted)
--dsc-file-upload-border-colorvar(--ds-color-border-default)
--dsc-file-upload-border-radiusvar(--ds-border-radius-md)
--dsc-file-upload-border-styledashed
--dsc-file-upload-border-style--hoversolid
--dsc-file-upload-border-widthmax(2px,0.125rem)
--dsc-file-upload-colorcurrentcolor
--dsc-file-upload-icon-colorvar(--ds-color-text-subtle)
--dsc-file-upload-icon-sizevar(--ds-size-8)
--dsc-file-upload-icon-urlurl('data
--dsc-file-upload-icon-url--readonlyurl('data
--dsc-file-upload-paddingvar(--ds-size-8) var(--ds-size-6)
Data Attributes
NameValue
data-fielddescription

React

react-dropzone

react-dropzone is a popular library for creating file upload components in React. Here is an example of how you can use react-dropzone together with FileUpload.

FileUpload

focusgroup
Type
string
focusgroupstart
Type
boolean
NameTypeDefaultDescription
focusgroupstring-

-

focusgroupstartboolean-

-

Edit this page on github.com (opens in a new tab)