Skip to main content

Toggle

A button control that switches between the pressed and unpressed states when the user clicks it.

Toggle button form control shown with an eye icon in pressed and unpressed states in DHTMLX Suite

Related sample: Form. All controls

Related sample: Form. Toggle

Adding Toggle​

You can add a Toggle control during form initialization:

const form = new dhx.Form("form_container", {
rows: [
{
type: "toggle",
name: "toggle",
icon: "dxi dxi-eye",
offIcon: "dxi dxi-eye-off",
text: "Visible",
offText: "Invisible"
}
]
});

Properties​

View the full list of Toggle configuration properties.

Working with Toggle​

You can manage a Toggle control with the methods and events of the object that the getItem() method returns.

For example, you can get the value of the control:

const value = form.getItem("toggle").getValue();

Methods​

Check the full list of Toggle methods.

Events​

Check the full list of Toggle events.