Developer Programs

Learn

Docs

Toggle

Components > Editing Data > Toggle
Use this component to...
Allow the user to change a Boolean value

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: @jkhy/responsive-ui-wc

Allows the user to change a Boolean value

NameTypeDefaultDescription
valuebooleanfalseBind this property to a backing value in your controller to set the initial value for the toggle.
rui-value-changeeventThis 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.
labelTextstring''If the toggle needs to be labeled, specify its label text with this property.
isDisabledbooleanfalseSpecifies whether the toggle is disabled.

Implementation

Begin by importing the rui-input module into your application.

Import the module
// import into app.module
import '@jkhy/responsive-ui-wc/components/rui-input/rui-input-imports';

Example:

Toggle HTML
<rui-toggle labelText="Show Passwords" [value]="showPasswords" (rui-value-change)="showPasswords = $event.detail"></rui-toggle>

Angular wrapper development

Wrapper reference

jha-toggle
jha-toggle
Module: JhaToggleModule - Package: @jkhy/responsive-ui-angular

Allows the user to change a Boolean value

NameTypeDefaultDescription
jhaToggleValbooleanfalseIf the toggle is part of a template-driven form, two-way bind this property to a backing value.
jhaLabelstring''If the toggle needs to be labeled, specify its label text with this property.
jhaIsDisabledbooleanfalseSpecifies whether the toggle is disabled.
jhaToggleValChangeeventThis event fires when the toggle’s value changes.

Implementation

Begin by importing the JhaToggleModule module into your application.

Import the module
// import into app.module
import { JhaToggleModule } from '@jkhy/responsive-ui-angular/jha-toggle';

@NgModule({
    imports: [
        ...
        JhaToggleModule,
        ...
    ]
})

export class AppModule(){}

Reactive form example:

Toggle HTML
<jha-toggle id="showPasswords" formControlName="showPasswords"></jha-toggle>

Template driven form example:

Toggle HTML
<jha-toggle id="showPasswords" [(jhaToggleVal)]="showPasswords"></jha-toggle>

Design

Figma design

Figma design info
You can find this component in the Components - Buttons page in the Figma UI Kit.
Dev ComponentDesign Component Name
Toggle

RUI / Buttons / Toggle

Switch on the Checked property if the toggle is on.


Adobe XD design

Adobe XD design info
You can find this component in these artboards in the Adobe XD design samples:
  • Sample App - Buttons
Dev ComponentDesign Component Name
Toggle - onJHA / Buttons / Toggle / On
Toggle - offJHA / Buttons / Toggle / Off

Support options
Have questions on this topic?
Join the Responsive UI team in Microsoft Teams to connect with the community.
See something in this page that needs to change?
Send us feedback on this page.
Last updated Tue Feb 13 2024