In Ruby on Rails, I was struggling for a long time to change the outline border on a Bootstrap Switch toggle button from a default blue outline to the colour I wanted, or finding any information on how to do it. I almost gave up, but then hacked together the solution below, with a lot of help from the stack on how to set the main button colour. But I was wondering if there is a cleaner and a better way than this, perhaps by sending another option into the bootstrapSwitch
function, as my hack below is a bit heavy-handed and ugly (though it does work, at least on my web page)?
CSS:
.bootstrap-switch .bootstrap-switch-handle-on.bootstrap-switch-purple,
.bootstrap-switch .bootstrap-switch-handle-off.bootstrap-switch-purple {
color: #fff;
background: #5126aa;
}
.bootstrap-switch.bootstrap-switch-focused {
border-color: #5126aa !important;
outline: 0 !important;
-webkit-box-shadow: inset 0 1px 1px rgba(81, 38, 170, 1), 0 0 8px rgba(81, 38, 170, 1) !important;
box-shadow: inset 0 1px 1px rgba(207, 220, 0, 0.4), 0 0 8px rgba(81, 38, 170, 1) !important;
}
Javascript at the bottom of the view ERB page:
<%= javascript_tag do %>
$(document).ready(function() {
$('input:checkbox').bootstrapSwitch({onColor: 'purple'});
});
<% end %>