Skip to main content

Custom Component

A custom-built React, or HTML and JavaScript, component.

This is a legacy component that is no longer supported. Use custom component libraries if you want to build custom components for Retool apps.

Custom Component supports passing data to and from the Retool app. It can be granted permission for popups, link redirection, and camera access.

You should only build a custom component if you need functionality that isn't already available in an existing component. You can also use an IFrame component to embed web pages or the HTML component to include custom HTML and CSS.

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.

allowCamera

Whether to allow access to a connected camera.

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

allowDownloads

Whether to allow downloads.

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

allowForms

Whether to allow form submissions.

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

allowFullscreen

Whether to allow fullscreen mode.

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

allowGeolocation

Whether to allow access to the user's location.

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

allowMicrophone

Whether to allow access to the microphone.

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

allowModals

Whether to allow modals.

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

allowPayments

Whether to allow payments using PaymentRequest().

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

allowPopups

Whether to allow popups.

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

allowPopupsToEscapeSandbox

Whether to allow popups to escape the sandbox.

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

allowSameOrigin

Whether to allow content to be treated as being from the same origin.

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

allowTopNavigation

Whether to allow navigation away from the app.

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

heightType

Whether the height automatically adjusts to fit content or is a fixed size.

Type string
Format Plain Text
Mutability
ControlUsage
Retool UI Inspector > Spacing > Height
Allowed Values
ValueDescription
fixed

Fixed height.

auto

Expand to fit content.

Default
fixed

hidden

Whether this object is hidden from view.

Type boolean
Format True/False
Mutability
ControlUsage
Retool UI Inspector > Appearance > Hidden
MethodsetHidden()
Default
false
Examples
true

id

The unique identifier (name).

Type string
Format Plain Text
Mutability
ControlUsage
Retool UI Inspector
Default
customComponent1
Examples
query1
button1

iframeCode

The HTML code to render.

Type string
Format HTML
Mutability
ControlUsage
Retool UI Inspector

isHiddenOnDesktop

Whether to show or hide this object in the desktop layout.

Type boolean
Format True/False
Mutability
ControlUsage
Retool UI Inspector > Appearance > Advanced > Show on desktop
Default
false
Examples
true

isHiddenOnMobile

Whether to show or hide this object in the mobile layout.

Type boolean
Format True/False
Mutability
ControlUsage
Retool UI Inspector > Appearance > Advanced > Show on mobile
Default
true
Examples
true

maintainSpaceWhenHidden

Whether to take up space on the canvas if hidden is true.

Type boolean
Format True/False
Mutability
ControlUsage
Retool UI Inspector > Appearance > Advanced > Maintain space when hidden
Default
false
Examples
true

margin

The amount of margin to render outside.

Type string
Format Plain Text
Mutability
ControlUsage
Retool UI Inspector > Spacing > Margin
Allowed Values
ValueUI OptionDescription
4px 8pxNormal

Normal margin.

0None

No margin.

Default
4px 8px
Examples
4px 8px

model

Dynamic data.

Type object
Mutability
ControlUsage
Retool UI Inspector
MethodupdateModel()

showInEditor

Whether the component remains visible in the editor if hidden is true.

Type boolean
Format True/False
Mutability
ControlUsage
Retool UI Inspector > Appearance > Advanced > Always show in edit mode
Default
false
Examples
true

style

Custom style options.

Type object
Mutability
ControlUsage
Retool UI Inspector > Appearance > style

Methods

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

customComponent.reload()

Reload the component.

Definition
customComponent.reload()
Examples

Reload customComponent.

customComponent.reload();

customComponent.scrollIntoView()

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

Definition
customComponent.scrollIntoView(options)
Parameters

options Required

object

The scroll options.

Object Properties

behavior Required

string

The scroll behavior.

Supported Values
autoScroll immediately to the specified position.
smoothScroll gradually to the specified position.

block Required

string

The scroll position relative to the component.

Supported Values
nearestScrolls 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.
startScrolls to position the component at the top of the visible area.
centerScrolls to position the component in the middle of the visible area.
endScrolls to position the component at the bottom of the visible area.
Examples

Scroll the minimum amount to immediately bring customComponent into view.

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

customComponent.updateModel()

Update the model with the specified value.

Definition
customComponent.updateModel(model)
Parameters

model

object

Dynamic data.


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