Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
How is this in terms of usability?
It's maybe not obvious you can switch those elements, is it still an intuitive way to represent a checkbox input?
You should probably add a hover state and not have the background be a light grey when off, as that commonly denotes a disabled input.
Also, a checkbox is commonly bordered. Not a must, but it's commonplace.
Required, but never shown