Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
How to make button act like checkbox? AKA CheckButton, PushButton
Hi friends,
I don't want to use Checkbox, I want to use button and have them in pressed mode, (Actually want On/Off switch on Button using Red/Green bulb-icon) ,
I tried switchMode in Button, but then it renders as a CheckBox.
So, Is there anyway, I can keep button in push mode? OR I can render CheckBox as a Button.
(Just for curiosity is there any difference in using CheckBox or Button with switchMode(true)?)
Cheers, :)
The easiest solution is to create custom component (extend Button or create composite with Button) and implement style switching logic. E.g., 1st click does addStyleName("on"), 2nd click -- removeStyleName("on"), etc. Support for more states (red, green, blue ...) could be implemented the same way.
Also check chameleon demo for how to use a normal button creatively by changing images and styles to implement a toggle button. (See Buttons page under Compound Styles)
Or how about just having the checkbox and theme it to look like a button?
Jens Jansson: Or how about just having the checkbox and theme it to look like a button?
One more solution: CustomCheckbox component from the Directory. Allows total control of the look of the checkbox, use images, don't use images. Just CSS.
Thanks,
Chameleon theme's Segment (Button Bar ) makes sense for me :)
And Switch button is cool too..
Cheers