Search code examples
javafxcontrolsfxtoggleswitch

Is it possible to change the ToggleSwitch colour in ControlsFX


I'm using ToggleSwitch in controlsFX which is wonderful. I'd like to change the colour from the default sky blue to another colour. I've used css styling but it changes the background behind the ToggleSwitch. Is there a way to customise the actual switch?

Here is my ToggleSwitch:

<ToggleSwitch styleClass="purple" text="No"/>

Here is my styling:

.purple{
-fx-background-color: #57379b
}

Solution

  • Style the background of the thumb area of a selected ToggleSwitch:

    .purple:selected .thumb-area {
        -fx-background-color: #57379b;
    }