Skip to main content

ToggleButton

Desc...

Properties

The ToggleButton widget inherits from IconButton class → Has all IconButton properties.
  • state: boolean → The orientation.
  • toggleOnIcon: string → The icon used when state is true. Default is toggle_on.
  • toggleOffIcon: string → The icon used when state is false. Default is toggle_off.

Constructor

ParameterTypeRequiredDescription
idstringyesThe id of the widget
textstringnoThe text of the label of the widget. Default is an empty string.
toggleOnIconstringnoThe icon used when state is true. Default is toggle_on.
toggleOffIconstringnoThe icon used when state is false. Default is toggle_off.
parentWidgetnoThe parent of the widget. Default is null
src/main.ts
import { ToggleButton } from "@cedro/ui";

const toggle: ToggleButton = new ToggleButton("my-toggle");

toggle.setState(true);

Public Methods

setState

Set the state of the toggle.

Parameters

ParameterTypeRequiredDescription
statebooleanyesThe state.

Returns Value

void

Example

src/main.ts
myToggle.setState(true);

toggle

Toggle the state of the toggle.

Parameters

void

Returns Value

void

Example

src/main.ts
myToggle.toggle();

getState

Get the state of the toggle.

Parameters

void

Returns Value

boolean

Example

src/main.ts
const state = myToggle.getState();