Button
Overview
Buttons trigger an action when pressed: they can execute code, route to another view in your application, or open a URL.
Text and icons
Buttons can display a text label, an icon, or both.
Styling
Buttons support the following styling:
- Use secondary styling for most buttons. The styling for secondary buttons is visually lighter to prevent the button from distracting the user’s eye from the data.
- Use primary styling for a button that performs the primary action in the view. The styling for primary buttons is visually heavy in order to draw attention to the button’s importance. There should be no more than one primary button in each view (or at most in each display block).
- Use destructive styling if pressing the button triggers a significant, destructive action like deletion.
- This button style should be used sparingly.
- If your application requires the user to confirm the destructive action after pressing a button — let’s say your app displays a confirmation dialog box — then the initial button that the user presses should not use destructive styling. However, you should use destructive styling on the destructive button option in the confirmation dialog.
Badges
Buttons can optionally display a short text message highlighted in the top-right corner of the button, called a badge. Badges are typically used either to display a count of data items that can be accessed when the user presses the button or to call the user’s attention to a special condition for the button.
Usage
Buttons can be used in the following locations…
![Function toolbar button example](./ButtonFunctionToolbar.png?v=2)
![Display block toolbar button example](./ButtonDisplayBlockToolbar.png?v=2)
![Floating toolbar button example](./ButtonFloatingToolbar.png?v=2)
![Templated list button example](./TemplatedListWithButtons.png?v=2)
Development
Web component development
Component reference
rui-button
Allows the user to trigger an action
Name | Type | Default | Description |
---|---|---|---|
text | string | '' | Text displayed in the button. |
buttonStyle | string | 'secondary' | Specifies the styling displayed for the button: One of “primary”, “secondary”, or “destructive”
|
buttonSize | string | 'medium' | Specifies the relative size of the button: One of “medium” or “small”
|
buttonType | string | 'button' | Specifies the type of button: One of “button” or “submit”
|
iconType | string | '' | The name of the icon to display in an icon button. You can find a list of all enterprise icons here. The use of custom icons is also supported. |
badge | string | '' | Optional text that is highlighted in the top-right corner of the button. Often used to display a count of data items that can be accessed when the user presses the button. |
isDisabled | boolean | false | Specifies whether the button is disabled. |
rui-click | event | Event fired when the user presses the button. | |
context | string | '' | This property is used internally. Leave it at its default value. |
Implementation
Begin by importing the rui-buttons
module into your application.
Use the rui-button
component to implement a button. Specify the button’s text with the text
property. Do not use the native HTML button element.
Define an rui-click
event handler to perform an action when the button is pressed.
Use buttonStyle
to specify the styling to use:
- Leave this property at its default of “secondary” for most buttons.
- Use a value of “primary” for a button that performs the primary action in the view. There should be no more than one primary button in each view (or at most in each display block).
- Use a value of “destructive” if pressing the button triggers a significant, destructive action like deletion. This button style should be used sparingly.
Bind isDisabled
to a value of true to disable the button.
Buttons in Responsive UI almost always display text as their content, but you can also display icon buttons in limited cases. To display an icon as the button content, set the iconType
property to one of the enterprise icon names. Use icon buttons sparingly, and only with standard icons that are very well understood by the user, such as print, edit, add-new, etc. You can find a list of all enterprise icons here.
Custom icons are also possible using the custom-icon slot. You can find more information on implementing custom icons on the icon component doc.
If you’re looking for more compactness for buttons in a toolbar, you can set the buttonSize
property to a value of “small”. This button size should only be used for buttons in a toolbar.
Angular wrapper development
Wrapper reference
jha-button
Allows the user to trigger an action
Name | Type | Default | Description |
---|---|---|---|
jhaText | string | '' | Text displayed in the button. |
jhaButtonStyle | string | 'Secondary' | Specifies the styling displayed for the button: One of “Primary”, “Secondary”, or “Destructive”
|
jhaButtonSize | string | 'Medium' | Specifies the relative size of the button: One of “Medium”, “Small”, or “Large”
|
jhaButtonType | string | 'button' | Specifies the type of button: One of “button” or “submit”
|
jhaIconType | string | '' | The name of the icon to display in an icon button. You can find a list of all enterprise icons here. The use of custom icons is also supported. |
jhaTooltip | string | '' | Tooltip displayed when the mouse hovers over the button |
jhaBadge | string | '' | Optional text that is highlighted in the top-right corner of the button. Often used to display a count of data items that can be accessed when the user presses the button. |
jhaIsDisabled | boolean | false | Specifies whether the button is disabled. |
jhaClick | event | Event fired when the user presses the button. | |
jhaRouterLink | string | '' | If the button links to a view within the app, this specifies the route for that view. |
jhaExternalUrl | string | '' | If the button links to a URL outside of the app, this specifies the URL. |
jhaExternalUrlInNewWindow | boolean | true | If the button links to a URL outside of the app, leave this at its default value of true if that link should open in a new tab/window, otherwise bind this to false. |
jhaWidth | string | 'auto' | Specifies the width of the button. Leave at the default value of ‘auto’ unless you need to specify a specific pixel or percentage width. Use CSS notation appropriate for the CSS “width” attribute. |
jhaThrottleClick
Directive to prevent double click.
Name | Type | Default | Description |
---|---|---|---|
See jhaThrottleClick for details. |
Implementation
Begin by importing the JhaButtonsModule
module into your application.
Use the jha-button
component to implement a button. Specify the button’s text with the jhaText
property. Do not use the native HTML button element.
A button performs an action when pressed. Use one of the following properties to specify the action performed when the button is pressed.
- If the button executes code, define a
jhaClick
event handler for it. - If the button links to a view within the app, specify the route for that view using the
jhaRouterLink
property. - If the button links to a URL outside of the app, specify the URL using the
jhaExternalUrl
property. Leave thejhaExternalUrlInNewWindow
property at its default value of true if that link should open in a new tab/window, otherwise bind this property to a value of false.
Use jhaButtonStyle
to specify the styling to use:
- Leave this property at its default of “Secondary” for most buttons.
- Use a value of “Primary” for a button that performs the primary action in the view. There should be no more than one primary button in each view (or at most in each display block).
- Use a value of “Destructive” if pressing the button triggers a significant, destructive action like deletion. This button style should be used sparingly.
Bind jhaIsDisabled
to a value of true to disable the button.
Buttons in Responsive UI almost always display text as their content, but you can also display icon buttons in limited cases. To display an icon as the button content, set the jhaIconType
property to one of the enterprise icon names. Use icon buttons sparingly, and only with standard icons that are very well understood by the user, such as print, edit, add-new, etc. You can find a list of all enterprise icons here.
Custom icons are also possible using the custom-icon slot. You can find more information on implementing custom icons on the icon component doc.
Buttons typically auto-size to fit their content, but in certain cases you may want to define a specific width for the button. You can use the jhaWidth
property to specify a specific pixel or percentage width. If you do this, use CSS notation appropriate for the CSS “width” attribute.
If you’re looking for more compactness for buttons in a toolbar, you can set the buttonSize
property to a value of “small”. This button size should only be used for buttons in a toolbar.
Component playground
Design
Figma design
Dev Component | Design Component Name |
---|---|
Text button | RUI / Buttons / Button Available values for the Style property:
Switch on the IconOnly property if the button only displays an icon. |
Button badge | RUI / Buttons / Badge Available values for the Style property:
|
Change the button text to an appropriate value. Resize the button to fit the text, but be careful that you’re resizing the outer component and not an inner layer within the component.
The button badge is supported for text and icon buttons only. If you want to display a badge on a button, drag the button badge design component to the artboard, layer it above the button it will appear on, change its text to an appropriate value, then center the badge on the top-right corner of the button.
Note that hover effects on buttons are currently not included. We could technically include these for prototypes, but it would require you to set the text twice for every button: once for the normal state and again for the hover state. So for now, we’ve left out hover effects. You can still wire up click interactions on buttons though.
Adobe XD design
- Sample App - Buttons
Dev Component | Design Component Name |
---|---|
Text button - primary | JHA / Buttons / Button / Primary |
Text button - secondary | JHA / Buttons / Button / Secondary |
Text button - destructive | JHA / Buttons / Button / Destructive |
Text button - disabled | JHA / Buttons / Button / Disabled |
Icon button - primary | JHA / Buttons / Icon Button / Primary |
Icon button - secondary | JHA / Buttons / Icon Button / Secondary |
Icon button - destructive | JHA / Buttons / Icon Button / Destructive |
Icon button - disabled | JHA / Buttons / Icon Button / Disabled |
Button badge | JHA / Buttons / Badge |
Change the button text to an appropriate value. Resize the button to fit the text, but be careful that you’re resizing the outer component and not an inner layer within the component.
The disabled state for all buttons and the on/off states for toggling buttons are internal states within the development components, but we have provided separate design components for these states for each type of button.
The button badge is supported for text and icon buttons only. If you want to display a badge on a button, drag the button badge design component to the artboard, layer it above the button it will appear on, change its text to an appropriate value, then center the badge on the top-right corner of the button.
Note that hover effects on buttons are currently not included. We could technically include these for prototypes, but it would require you to set the text twice for every button: once for the normal state and again for the hover state. So for now, we’ve left out hover effects. You can still wire up click interactions on buttons though.