Consider this switch:
<Switch class="switch" formControlName="answer"></Switch>
If I do this it only works when you haven't activated the switch yet, after that the background-color will always be the same even when the switch is not active:
.switch[checked=true] {
background-color: #FE4A49;
color: #FE4A49;
}
And if I do this:
.switch {
background-color: #FE4A49;
color: #FE4A49;
}
Then the background will always be the same regardless of the state.
What's the correct way of styling a switch when using it with angular's model bindings?
i'm styling an App and this is i'd do.
CSS:
Switch#userStatus[checked=true]{
color:#ff0048 ;
background-color: white;
transform: scale(1.25, 1.25); // This is for change the size when checked
transform: translate(-5,0); // This is for stay the position after scale it
}
Switch#userStatus[checked=false]{
color: gray;
background-color: gray;
}
And this is my XML:
`<Switch id="userStatus" checked="false" />`
I hope this helps!
I had an issue with switch
background-color
and it was not working as expected. Changing the background-color was changing the whole switch (the gray part). So I had to change only the color property:
Switch[checked=true] {
color: #f68533;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With