Skip to main content
Question

How to remove an image from a Figma widget?

  • January 13, 2024
  • 1 reply
  • 564 views

I’m building a Figma widget with typescript. The widget lets me upload the image but won’t let me remove the image from the widget. Does anybody know what I’m missing?

if (props.imageString == '') {
      return (
        <FileUploadDropzone
          onSelectedFiles={handleSelectedFiles}
        >
          <Text align="center">
            <Muted>Click or Drop Your Image Here</Muted>
          </Text>

        </FileUploadDropzone>
      )
    }

    if (props.imageString && props.imageString !== '') {
      return (
        <Fragment>
          <div className={styles.uploadedFileArea}>
            <Text align="center">
              <Muted>Remove Image</Muted>
            </Text>
            <IconCross32 />
          </div>
        </Fragment>
      )
    }

    return null
This topic has been closed for replies.

1 reply

figajm
Figmate
  • Figmate
  • 5 replies
  • January 16, 2024

A few questions:

  • What library are you using for the FileUploadDropzone?
  • There should likely be some sort of handler on the Text component (similar to the onSelectedFiles={handleSelectedFiles} handler on the FileUploadDropzone component) that handles clicks on that text and removes the image. You might check the documentation for the library you’re using for examples to this effect.

Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings