Toggle
Components
>
Editing Data
>
Toggle
Use this component to...
Allow the user to change a Boolean value
See this component in action...
Overview
Use the toggle component to allow the user to change a Boolean value.
The toggle acts like a physical switch that allows users to turn things on or off, like a light switch.
If a label is specified, it displays to the right of the toggle.
Development
Web component development
Component reference
rui-toggle
rui-toggle
Module: rui-input
-
Package: @jha/rui-wc
Allows the user to change a Boolean value
Name | Type | Default | Description |
---|---|---|---|
value | boolean | false | Bind this property to a backing value in your controller to set the initial value for the toggle. |
rui-value-change | event | This event fires when the toggle’s value changes. The new value is passed in the event detail. Use this event to update the backing value in your controller. | |
labelText | string | '' | If the toggle needs to be labeled, specify its label text with this property. |
isDisabled | boolean | false | Specifies whether the toggle is disabled. |
Implementation
Begin by importing the rui-input
module into your application.
// import into app.module
import '@jha/rui-wc/components/rui-input/rui-input-imports';
Example:
<rui-toggle labelText="Show Passwords" [value]="showPasswords" (rui-value-change)="showPasswords = $event.detail"></rui-toggle>
Angular component development
Component reference
jha-toggle
jha-toggle
Module: JhaToggleModule
-
Package: @jha/jharesponsive
Allows the user to change a Boolean value
Name | Type | Default | Description |
---|---|---|---|
jhaToggleVal | boolean | false | If the toggle is part of a template-driven form, two-way bind this property to a backing value. |
jhaIsReactive | boolean | false | If the toggle is part of a reactive form, set this property to true and set the formControlName attribute for the field. |
jhaIsDisabled | boolean | false | Specifies whether the toggle is disabled. |
jhaToggleValChange | event | This event fires when the toggle’s value changes. | |
jhaToggleBlur | event | If jhaIsReactive is set to false, the jhaToggleBlur event fires when the toggle’s blur event is triggered. |
Implementation
Begin by importing the JhaToggleModule
module into your application.
// import into app.module
import { JhaToggleModule } from '@jha/jharesponsive/jha-toggle';
@NgModule({
imports: [
...
JhaToggleModule,
...
]
})
export class AppModule(){}
Reactive form example:
<jha-toggle id="showPasswords" formControlName="showPasswords" [jhaIsReactive]="true"></jha-toggle>
Template driven form example:
<jha-toggle id="showPasswords" [(jhaToggleVal)]="showPasswords" (jhaToggleBlur)="toggleBlur($event);"></jha-toggle>
Design
Figma design
Figma design info
Dev Component | Design Component Name |
---|---|
Toggle |
RUI / Buttons / Toggle Switch on the Checked property if the toggle is on. |
Adobe XD design
Adobe XD design info
- Sample App - Buttons
Dev Component | Design Component Name |
---|---|
Toggle - on | JHA / Buttons / Toggle / On |
Toggle - off | JHA / Buttons / Toggle / Off |
Support options
Last updated Wed Mar 29 2023