Toggle Button in CUBA?

How to create a Toggle Button in CUBA?

Sorry, but your question is extremely unclear. What have you tried so far? Please be specific, provide context and details. Also, take a look at our forum guidelines.

Regards,
Gleb

Hi Ranjisona,

if i guessed correctly, you want a button that tracks a certain state, if that’s the case, then the solution is in the controller of the screen, you need to do the following:

  • create a button with it’s caption as the initial state.
  • inject the button in the screen controller.
  • create an action on the screen itself.
  • link the button to that action.
  • in the action handler, you can have your logic that changes the caption of the button to the desired state. if required you can even set the button to readonly one it reaches the final state.

not sure if this is what you are looking for.

Instead of normal button , I want to create toggle button like this and attach image for that toggle

The one way is integrating either a Third-party Vaadin Component or a JavaScript library. For example, Switch - Vaadin Add-on Directory.

Alternatively, you can try styling the CheckBox component to make it look like a Toggle Switch.

Regard,
Gleb

1 Like