Button
This page provides information on the button widget, enabling you to trigger actions or perform specific tasks with a simple click.
Content properties
These properties are customizable options present in the property pane of the widget, allowing users to modify the widget according to their preferences.
Basic
Label string
Sets the text that appears on the button.
onClick
Allows you to configure one or multiple actions (Framework functions, queries, or JS functions) to be executed when the button is clicked. You can chain multiple actions together, and all the nested actions would run simultaneously.
General
Tooltip string
Sets a tooltip that appears when the user hovers over the widget. It enables you to add hints or provide additional information for the button.
Visible boolean
Controls the visibility of the widget. If you turn off this property, the widget is not visible in View mode. Additionally, you can use JavaScript by clicking on JS next to the Visible property to control the widget's visibility conditionally.
For example, if you want to make the button visible only when the user selects "Yes" from a Select widget, you can use the following JavaScript expression:
{{Select1.selectedOptionValue === "Yes"}}
Disabled boolean
Prevents users from selecting the widget. Even though the widget remains visible, user input is not permitted. Additionally, you can use JavaScript by clicking on JS next to the Disabled property to control the widget's disabled
state conditionally.
For example, if you want to allow only a specific user to click the button, you can use the following JavaScript expression:
{{appsmith.user.email=="john@appsmith.com"?false:true}}
Animate Loading boolean
Controls whether the widget is displayed with a loading animation. When enabled, the widget shows a skeletal animation during the loading process. Additionally, you can control it through JavaScript by clicking on the JS next to the property.
Validation
Google reCAPTCHA key
Add a Google reCAPTCHA site key here to enable Google reCAPTCHA check to the button. The token is accessible from the API pane with the recaptchaToken
key (see the Google reCAPTCHA docs). Read more about using Google reCAPTCHA Keys in Appsmith.
Google reCAPTCHA version
Sets the Google reCAPTCHA version to use for the button, either v2 or v3.
Form settings
Buttons can have some special behaviors when they're located within the boundaries of a Form widget. Its form-specific behavior is controlled by two of the button's properties:
Disabled invalid forms
When this button property is turned on, the button remains disabled if the associated form contains any required fields that are incomplete or if any of the form fields contain input that is considered invalid.
For example, if you have a form with an Input widget whose Required property is turned on. If that input field hasn't been completed by the user, then the button won't be usable.
Reset form on success
When this button property is turned on, the button can be used to reset all fields present in the form's area to their default state. This is useful for clearing inputs after the form is submitted.
Style properties
Style properties allow you to change the look and feel of the button.
General
Button variant string
Specifies the style type of the button to indicate its significance.
Options:
- Primary: Fills the button with color.
- Secondary: Adds a colored border to the button while keeping the button itself white.
- Tertiary: This option does not apply any specific styling changes to the button.
This property can be dynamically set using JavaScript by providing a string value of PRIMARY
, SECONDARY
, or TERTIARY
.
Icon
Select icon string
Specifies the icon to be displayed on the button. Additionally, you can use JS to dynamically set the icon. You can refer to the documentation of blueprintjs to explore a wide range of available icons.