button (v1) (deprecated)
button
(v1) is deprecated
Support for button
v1 has been dropped from the JourneyApps Runtime. Please upgrade to button
v3 to ensure that your app remains compatible with the latest versions of the JourneyApps Runtime.
Three variations of buttons are available in JourneyApps:
Regular buttons
Menu buttons - which is a
button
placed inside amenu
component.Primary button - which is fixed to the bottom of the view and spans its full width.
Buttons can be used to trigger functions:
Calling a JavaScript/TypeScript function - by specifying
on-press="example_function()"
.Calling link functions directly - by specifying
on-press="link.view_path()"
.
Using Buttons
Buttons should be used when you need a user to perform a specific action on your view. They should be worded clearly so that users know what will happen when they click it. In general, a view shouldn't contain too many buttons, otherwise they start to compete with one another and overwhelm the user. If you find yourself using buttons everywhere, you may need to determine whether your view has too many actions on it, or whether a list
would work better instead.
Buttons are appropriate for actions such as "create", "add", "new", "edit", "update", "complete", "save", "proceed", "log in", etc.
Regular Button
Menu Button
Primary Button (Special Case)
A special case of the Regular Button is also available. This button is displayed on the bottom of the screen and spans the entire width (excluding sidebar). Use this button when your page has one main call-to-action. These buttons work well for actions like "Done" / "Complete" / "Log in" / "Proceed".
A button can be made into a Primary button by adding type="primary"
to its tag:
Configuration
label
required
Text to display on the button. It can be a format string to make the text dynamic. To have no label, specify label=""
.
on-press
optional
Function to call when the button is pressed - either a JavaScript/TypeScript function or a navigation function.
validate
optional
Set to true
to run validations when this button is pressed (in other words, check whether any required input fields are not empty), before running the action or opening the link. Set to false
to disable validations when this button is pressed. The value can also be the result of a function (e.g. $:shouldBeValidated()
). Defaults to true
.
type
optional
Setting type="primary"
will cause the button to be displayed in the top right corner on tablets.
show-if
optional
Controls whether the component is hidden or shown. The argument specified to show-if
can either be a literal boolean value (true
or false
), or it can specify a variable, parameter or field that can be a string, number, object, etc. that evaluates to false or evaluates to true. If the component also specifies required="true"
, but it is hidden, the validation will be ignored/skipped.
hide-if
optional
The opposite of show-if
(see above).
disabled
optional
true
, false
, a view variable (e.g. my_var
) or the result of a function (e.g. $:shouldBeDisabled()
). When resolved to true
, the button is grayed out and not clickable (Available from JourneyApps Container v4.23.0)
disabled-message
optional
Text to display when the user clicks on a disabled button (Available from JourneyApps Container v4.23.0)
Configuration specific to Menu Buttons
The following apply only to menu
buttons (i.e. button
inside a menu component).
icon
optional
The icon to display on the button, left of the text. The icon can be a Font Awesome icon, an Ionicons icon or the path of a custom icon (icons upload using the Assets workspace in OXIDE)
subtext
optional
Text to display below the normal button text, in a smaller font. It can be a format string to make the text dynamic.
See Also
The menu
component can be used to render buttons in a menu. However, the recommended way of creating menus is now using the list
component.
Last updated