Skip to main content

The File Button component for Retool Apps

A button to select single or multiple files.

Refer to the File inputs guide for more information on how to use this component.

Properties

All properties for this object with supported data types or values. You can write JavaScript almost anywhere in Retool to manipulate or read property values.

accept

A list of file extensions or file-type specifiers to accept.

Type array
Array values string
Mutability
ControlUsage
Retool UI Inspector
Examples
["image/*", "pdf", "doc"]

appendNewSelection

Whether to append additional files to the value.

Type boolean
Mutability
ControlUsage
Retool UI Inspector

disabled

Whether input, interaction, selection, or triggering is disabled.

Type boolean
Format True/False
Mutability
ControlUsage
Retool UI Inspector > Interaction > Disabled
MethodsetDisabled()
Default
false
Examples
true

files

A list of metadata from the selected files.

Type array
Array values object
Mutability Read-only
Array Object Properties

lastModified

The last modified date as a timestamp.

Type number
Format Timestamp
Mutability Read-only
Examples
1617024000000

name

The file name with extension.

Type string
Mutability Read-only

retoolStorageId

The file ID if uploaded to Retool Storage.

Type string
Mutability Read-only

size

The file size, in bytes.

Type string
Mutability Read-only

type

The MIME type.

Type string
Mutability Read-only

uploading

Whether the file is uploading.

Type boolean
Mutability Read-only


iconAfter

The suffix icon to display.

Type string
Format Icon Key
Mutability
ControlUsage
Retool UI Inspector > Content > Add-ons > Suffix icon
Default
null
Examples
/icon:bold/shopping-gift

iconBefore

The prefix icon to display.

Type string
Format Icon Key
Mutability
ControlUsage
Retool UI Inspector > Content > Add-ons > Prefix icon
Default
null
Examples
/icon:bold/shopping-gift

isPublic

Whether to make the file public when uploading with Retool Storage.

Type boolean
Mutability
ControlUsage
Retool UI Inspector

loaderPosition

The position of the loading indicator if loading is true.

Type string
Mutability
ControlUsage
Retool UI Inspector > Interaction > Loader position
Allowed Values
ValueDescription
auto

Position automatically.

replace

Replace the text.

left

Left of text.

right

Right of text.

Default
auto

loading

Whether to display a loading indicator.

Type boolean
Format True/False
Mutability
ControlUsage
Retool UI Inspector > Interaction > Loading
Default
false
Examples
true

maxCount

The maximum number of items to allow.

Type number
Mutability
ControlUsage
Retool UI Inspector

maxSize

The maximum file size allowed.

Type number
Mutability
ControlUsage
Retool UI Inspector

minCount

The minimum number of items to allow.

Type number
Mutability
ControlUsage
Retool UI Inspector

minSize

The minimum file size allowed.

Type number
Mutability
ControlUsage
Retool UI Inspector

parsedValue

The parsed value of the input.

Type array
Array values string
Mutability Read-only

parseFiles

Whether to parse plain-text content.

Type boolean
Mutability
ControlUsage
Retool UI Inspector

parsing

Whether content is being parsed.

Type boolean
Mutability Read-only

selectionType

The type of file selection.

Type string
Mutability
ControlUsage
Retool UI Inspector
Allowed Values
ValueDescription
single

Select a single file.

multiple

Select multiple files.

directory

Select a directory of files.


shouldOverwriteOnNameCollision

Whether to replace a file with the same name when uploading with Retool Storage.

Type boolean
Mutability
ControlUsage
Retool UI Inspector

style

Custom style options.

Type object
Mutability
ControlUsage
Retool UI Inspector > Appearance > style

styleVariant

The style variant to use.

Type string
Format Plain Text
Mutability
ControlUsage
Retool UI Inspector > Appearance > Variant
Allowed Values
ValueDescription
solid

Solid style.

outline

Outline style.

Default
solid
Examples
solid

text

The primary text content.

Type string
Format Plain Text
Mutability
ControlUsage
Retool UI Inspector > Content > Add-ons > Text
Examples
Submit

uploadToRetoolStorage

Whether to upload a file to Retool Storage.

Type boolean
Mutability
ControlUsage
Retool UI Inspector

value

A list of uploaded files.

Type array
Mutability Read-only

Methods

JavaScript API methods for this object. You can write JavaScript almost anywhere in Retool and use methods to manipulate data and property values.

fileButton.clearValidation()

Clear the validation message from the input field.

Definition
fileButton.clearValidation()
Examples

Clear the validation message from fileButton.

fileButton.clearValidation();

fileButton.clearValue()

Clear the current values.

Definition
fileButton.clearValue()
Examples

Clear the current value of fileButton.

fileButton.clearValue();

fileButton.focus()

Set focus on the input field.

Definition
fileButton.focus()
Examples

Set focus on fileButton.

fileButton.focus();

fileButton.resetValue()

Reset the current value to the default value.

Definition
fileButton.resetValue()
Examples

Reset the current value of fileButton.

fileButton.resetValue();

fileButton.scrollIntoView()

Scrolls the canvas or parent container so that the selected component appears in the visible area.

Definition
fileButton.scrollIntoView(options)
Parameters

options

The scroll options.

Type object
Object Properties

behavior

The scroll behavior.

Type string
Allowed Values
ValueDescription
auto

Scroll immediately to the specified position.

smooth

Scroll gradually to the specified position.


block

The scroll position relative to the component.

Type string
Allowed Values
ValueDescription
nearest

Scrolls only the minimum amount required for the component to appear in the visible area. Scrolling does not occur if the component is already in view.

start

Scrolls to position the component at the top of the visible area.

center

Scrolls to position the component in the middle of the visible area.

end

Scrolls to position the component at the bottom of the visible area.



Examples

Scroll the minimum amount to immediately bring fileButton into view.

fileButton.scrollIntoView({behavior: 'auto', block: 'nearest'});

fileButton.setDisabled()

Set the disabled value to toggle whether the input field is disabled. Defaults to true without a parameter.

Definition
fileButton.setDisabled(disabled)
Parameters

disabled

Whether input, interaction, selection, or triggering is disabled.

Type boolean
Format True/False
Default
false
Examples
true

Examples

Disable fileButton.

fileButton.setDisabled(true);

Enable fileButton.

fileButton.setDisabled(false);

fileButton.setHidden()

Set the hidden value to toggle whether the component is visible. Defaults to true without a parameter.

Definition
fileButton.setHidden(hidden)
Parameters

hidden

Whether this object is hidden from view.

Type boolean
Format True/False
Default
false
Examples
true

Examples

Hide fileButton.

fileButton.setHidden(true);

Unhide fileButton.

fileButton.setHidden(false);

fileButton.validate()

Validates the value of the input field.

Definition
fileButton.validate()
Examples

Validate the value of fileButton.

fileButton.validate();

Events

Events triggered by user interactions. You can configure event handlers in the IDE to trigger queries or other actions in response to events.

EventDescription
ChangeThe value is changed.
ParseData is parsed.