<div dir="ltr"><div dir="ltr">Hi all,<br><br>I'd like to discuss the possibility of adding a SwitchButton control to JavaFX.<br><br>## Motivation<br><br>The switch control has become a standard UI element across all major platforms:<br>- iOS/macOS: Toggle<br>- Android: MaterialSwitch<br>- Flutter: Switch, CupertinoSwitch<br>- Windows (WinUI): ToggleSwitch<br><br>Currently, JavaFX lacks a native Switch control.<br><br>## Why Not CheckBox or ToggleButton?<br><br>The visual form is fundamentally different:<br>- CheckBox: box + checkmark<br>- ToggleButton: button with pressed/released states<br>- SwitchButton: sliding track + circular thumb<br><br>Beyond appearance, SwitchButton is also semantically unique:<br>- Unlike CheckBox: no indeterminate state, takes effect immediately (not form submission)<br>- Unlike ToggleButton: no ToggleGroup support, designed for independent on/off settings<br><br>## Why Not ControlsFX's ToggleSwitch?<br><br>ControlsFX's ToggleSwitch has served the community well, but has architectural issues:<br><br>1. **Control level**: Extends Labeled instead of ButtonBase (inconsistent with CheckBox/RadioButton/ToggleButton)<br><br>2. **Skin level**: ToggleSwitchSkin extends SkinBase<ToggleSwitch> instead of LabeledSkinBase, so it cannot reuse the label layout logic. It creates an internal Label, which causes most Labeled properties (textFill, graphic, contentDisplay) to not work as expected.<br><br>Fixing these would require rewriting 80%+ of the code and break existing users. Given that Switch is a fundamental UI component, it makes sense to include it in JavaFX core.<br><br>## Prototype<br><br>I've created a working implementation:<br>- Showcase: <a href="https://github.com/leewyatt/SwitchButtonShowcase">https://github.com/leewyatt/SwitchButtonShowcase</a><br>- Implementation: <a href="https://github.com/leewyatt/jfx/tree/add-switch-button-v2">https://github.com/leewyatt/jfx/tree/add-switch-button-v2</a><br><br>Key design decisions:<br>- Extends ButtonBase (consistent with other toggle controls)<br>- Skin extends LabeledSkinBase (full Labeled property support)<br>- Styles for both Modena and Caspian themes<br><br>I'd appreciate any feedback on whether this would be a valuable addition to JavaFX core.<br><br>Thanks,<br>Lee</div>
</div>