Skip to main content

File Button

File Button is a button component that opens the file picker dialog when clicked, allowing users to select and upload files. Once files are selected, the button label updates to show the selected file count, and the file data is made available through exposed variables for use in queries and other components.

Example Usage

A logistics company builds an internal tool for processing bulk shipment orders. Employees click the File Button to upload a CSV file containing hundreds of order entries. The parsed CSV data is then bound to a table query that inserts each row into the database — eliminating manual data entry entirely.

Properties

PropertyDescriptionExpected Value
Button textThe label shown on the button before any file is selected. Updates to show file count after selection.String (e.g., Upload file). Default: Upload file.
Enable multiple filesAllows users to select more than one file at a time.Toggle on/off or use fx to set {{true}} or {{false}}. Default: false.
Parse file contentWhen enabled, ToolJet automatically reads and parses the content of selected files into structured data.Toggle on/off or use fx to set {{true}} or {{false}}. Default: false.
File typeSpecifies the format ToolJet uses to parse the file content. Only shown when Parse file content is enabled.Select one of: Autodetect from extension, CSV, XLS, XLSX, JSON. Default: Autodetect from extension.
DelimiterThe character used to separate values when parsing CSV files. Only shown when Parse file content is enabled and File type is CSV.String (e.g., , or ;). Default: ,.

Events

EventDescription
On file selectedFires immediately when the user picks a file from the dialog, before content is read.
On file loadedFires after the file has been fully read and processed by ToolJet.

Component Specific Actions (CSA)

Following actions of File Button component can be controlled using the component specific actions(CSA):

Action
Description
How To Access
clear()Clears all selected files and resets the button label.Use a RunJS query: await components.filebutton1.clear() or trigger it using an event.
setFocus()Brings focus to the file button.Use a RunJS query: await components.filebutton1.setFocus() or trigger it using an event.
setBlur()Removes focus from the file button.Use a RunJS query: await components.filebutton1.setBlur() or trigger it using an event.
setVisibility()Shows or hides the component.Use a RunJS query: await components.filebutton1.setVisibility(true) or trigger it using an event.
setDisable()Enables or disables the component.Use a RunJS query: await components.filebutton1.setDisable(true) or trigger it using an event.
setLoading()Toggles the loading spinner on the button.Use a RunJS query: await components.filebutton1.setLoading(true) or trigger it using an event.

Exposed Variables

VariableDescriptionHow To Access
filesArray of processed file objects. Each object contains name, size, type, content (raw text), base64Data, parsedValue (structured parsed data), and lastModified.{{components.filebutton1.files}}
fileSizeTotal size in bytes of all currently selected files.{{components.filebutton1.fileSize}}
isParsingtrue while ToolJet is actively reading and parsing file content.{{components.filebutton1.isParsing}}
isValidtrue when the component's validation rules are satisfied (mandatory check and min file count).{{components.filebutton1.isValid}}
isMandatorytrue when the Make this field mandatory validation option is enabled.{{components.filebutton1.isMandatory}}
isLoadingtrue when the component is in loading state.{{components.filebutton1.isLoading}}
isVisibletrue when the component is visible.{{components.filebutton1.isVisible}}
isDisabledtrue when the component is disabled.{{components.filebutton1.isDisabled}}

Validation

Validation Option
Description
Expected Value
Make this field mandatoryMarks the file selection as required. Shows an error message if the user submits without selecting a file.Toggle on/off or use fx. Default: false.
File typeRestricts which file types the picker will accept. Supports MIME types and extensions.String (e.g., image/*, .pdf, image/png,.pdf). Default: */* (all types).
Min size (bytes)The minimum allowed size for each file. Files smaller than this are rejected.Number (e.g., 1024 for 1 KB). Default: 0.
Max size (bytes)The maximum allowed size for each file. Files larger than this are rejected.Number (e.g., 1048576 for 1 MB). Default: 1048576.
Min file countThe minimum number of files that must be selected. Only shown when Enable multiple files is on.Number (e.g., 1). Default: 1.
Max file countThe maximum number of files that can be selected. Only shown when Enable multiple files is on.Number (e.g., 5). Default: 2.

Additional Actions

Action
Description
Configuration Options
Enable clear selectionShows an × button inside the file button after files are selected, allowing users to clear the selection without clicking the button again.Enable/disable the toggle button or dynamically configure the value by clicking on fx and entering a logical expression.
Loading stateEnables a loading spinner, often used with isLoading to indicate progress.Enable/disable the toggle button or dynamically configure the value by clicking on fx and entering a logical expression.
VisibilityControls component visibility.Enable/disable the toggle button or dynamically configure the value by clicking on fx and entering a logical expression.
DisableEnables or disables the component.Enable/disable the toggle button or dynamically configure the value by clicking on fx and entering a logical expression.
TooltipProvides additional information on hover.String (e.g., Click to upload a file).

Devices

Property
Description
Expected Value
Show on desktopMakes the component visible in desktop view.You can set it with the toggle button or dynamically configure the value by clicking on fx and entering a logical expression.
Show on mobileMakes the component visible in mobile view.You can set it with the toggle button or dynamically configure the value by clicking on fx and entering a logical expression.

Styles

Label and Icon

Property
Description
Configuration Options
Label sizeSets the font size of the button label.Number in pixels (e.g., 14). Default: 14.
Label weightSets the font weight of the button label.Select Normal, Medium, or Bold. Default: Medium.
Label colorSets the color of the button label text.Select a color using the color picker or set programmatically with fx using a hex code.
IconSets an icon displayed alongside the button label.Enable icon visibility, then select the desired icon from the icon picker.
Icon colorSets the color of the icon.Select a color using the color picker or set programmatically with fx.
Icon directionControls whether the icon appears to the left or right of the label.Select Left or Right.
Loader colorSets the color of the loading spinner shown when the button is in loading state.Select a color using the color picker or set programmatically with fx.
Content alignmentControls the horizontal alignment of the button content (label and icon).Select Left, Center, or Right.

Button

Property
Description
Configuration Options
Button typeSets the visual style of the button.Select Solid for a filled button or Outline for a transparent button with a border. Default: Solid.
BackgroundSets the background color of the button. Only available when Button type is Solid.Select a color using the color picker or set programmatically with fx using a hex code.
Border radiusControls the roundness of the button corners.Number in pixels (e.g., 6). Default: 6.
Box shadowAdds a shadow effect to the button. Only available when Button type is Solid.Use the shadow editor or set programmatically with fx.
PaddingControls whether the button uses default padding or no padding.Select Default or None.


Need Help?