Toggle Button
Overview
Toggle buttons allow the user to quickly toggle a boolean state on or off in a toolbar. Examples might include turning a formatting option like Bold or Italic on/off or showing/hiding a subset of data.
Use a toggle button for toggling a boolean value from a toolbar. Use a checkbox for toggling a boolean value in a form.
Development
Web component development
Component reference
rui-toggle-button
Toggles a boolean value when pressed
Name | Type | Default | Description |
---|---|---|---|
value | boolean | false | Bind this to a boolean value in your controller to specify the initial true/false value for the toggle button. |
rui-value-change | event | Event fired when the toggle button changes its value. The new value is passed as the event detail. | |
buttonSize | string | 'medium' | One of “medium” or “small”. You’ll typically use the default value of “medium”, although you can use the “small” size for buttons in a toolbar if you’re looking for more compactness. |
isDisabled | boolean | false | Specifies whether the button is disabled. |
Implementation
Begin by importing the rui-buttons
module into your application.
Use rui-toggle-button
to allow the user to quickly toggle an internal state off or on using a toolbar button. Bind value
to a boolean backing value in your controller that tracks the internal state. Add a rui-value-change
event handler to update the backing value when the state changes internally within the component. Place the button content within the open and close tags for the component.
Angular wrapper development
Wrapper reference
jha-toggle-button
Toggles a boolean value when pressed
Name | Type | Default | Description |
---|---|---|---|
jhaValue | boolean | false | Use two-way binding to bind this to a boolean value in your TypeScript that tracks a particular internal state. You must use two-way binding because this value can be changed both within the toggle button and within your TypeScript, so the two must be kept in sync. |
jhaValueChange | event | Event fired when the toggle button changes its value. You’ll often use *ngIf to update parts of your app when the toggled boolean value changes, but if you also need to perform other programmatic actions, use this event to do so whenever this value changes. | |
jhaButtonSize | string | 'Medium' | One of “Medium” or “Small”. You’ll typically use the default value of “Medium”, although you can use the “Small” size for buttons in a toolbar if you’re looking for more compactness. |
jhaTooltip | string | '' | Tooltip displayed when the mouse hovers over the button |
jhaIsDisabled | boolean | false | Specifies whether the button is disabled. |
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 jha-toggle-button
to allow the user to quickly toggle an internal state off or on using a toolbar button. Bind jhaValue
to a boolean backing value in your controller that tracks the internal state. Add a jhaValueChanged
event handler to update the backing value when the state changes internally within the component. Place the button content within the open and close tags for the component.
Component playground
Design
Figma design
Dev Component | Design Component Name |
---|---|
Toggle button | RUI / Buttons / Toggle Button
|
Adobe XD design
- Sample App - Buttons
Dev Component | Design Component Name |
---|---|
Toggle text button - on | JHA / Buttons / Toggle Text Button / On |
Toggle text button - off | JHA / Buttons / Toggle Text Button / Off |
Toggle icon button - on | JHA / Buttons / Toggle Icon Button / On |
Toggle icon button - off | JHA / Buttons / Toggle Icon Button / Off |