Skip to main content

Toggle

A special button control that changes its state from pressed to the unpressed one when clicked.

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 easily add a Toggle control during initialization of a form:

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 configuration properties of the Toggle control.

Working with Toggle

You can manipulate a Toggle control by using methods or events of the object returned by the getItem() method.

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

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

Methods

Check the full list of methods of the Toggle control.

Events

Check the full list of events of the Toggle control.