Grapes homepage1.57.0
  • Guide
  • Tokens
  • Components
    Grapes on GithubGrapes on Figma
    Interaction
    • Button
    • IconButton
    • FloatingActionBar
    • Link
    Icons
    • Icon
    • HighlightIcon
    Form
    • AmountInput
    • Autocomplete
    • AutocompleteMultiple
    • AutocompletePlace
    • CheckboxBox
    • CheckboxField
    • DatePicker
    • FormField
    • Input
    • OptionGroup
    • PasswordInput
    • PhoneInput
    • RadioBox
    • RadioField
    • RadioGroup
    • Select
    • SwitchField
    • TextArea
    • TextInput
    • Upload
    • UploadButton
    Feedback
    • Badge
    • Banner
    • Callout
    • EmptyState
    • Modal
    • ModalSlideshow
    • DeprecatedModalSlideshow
    • PageModal
    • Skeleton
    • Tag
    • Toast
    • Tooltip
    Data display
    • Accordion
    • Avatar
    • Box
    • Calendar
    • CalendarRange
    • CollapsibleList
    • FileCard
    • InfoTip
    • ListBox
    • ListView
    • Panel
    • SidePanel
    • DeprecatedPreview
    • Table
    • Timeline
    • useDateFormatter
    Navigation
    • DropdownItem
    • DropdownMenu
    • Navigation
    • NavigationItem
    • Popover
    • Tabs

    Upload

    The Upload component allows users to upload a file manually or using drag and drop.

    View source code
    • Usage
    • Props

    Basic usage

    const Demo = () => {
      const [selectedFile, setSelectedFile] = useState<File>();
    
      return selectedFile ? (
        <FileCard
          title={selectedFile.name}
          mimeType={selectedFile.type}
          onDelete={() => setSelectedFile(undefined)}
        />
      ) : (
        <Upload
          content={
            <span>
              Drag & drop file(s) here <br />
              or <u>import them from your computer</u>
            </span>
          }
          activeDragContent="Upload file(s)"
          onUpload={async (filesToUpload) => {
            setSelectedFile(filesToUpload?.[0]);
          }}
        />
      );
    };
    

    Illustration

    You can display an illustration instead of the default icon with the illustration prop.

    <Upload
      illustration={<img src="/illustration.webp" alt="" />}
      {...otherProps}
    />
    

    Accept specific file types

    The accept prop is used to allow one or more unique file types.

    <Upload accept="image/*" {...otherProps} />