Recently, I've been creating toggle switches using a single HTML element (an input of type checkbox) and CSS. No JavaScript, no external images.
Toggle switches collection: https://codepen.io/collection/aMPYMo
Quick links to the toggles in this video (in order of appearance):
00:01 - Bobbly: https://codepen.io/alvaromontoro/pen/...
00:11 - Wooden (II): https://codepen.io/alvaromontoro/pen/...
00:17 - Coffee - https://codepen.io/alvaromontoro/pen/...
00:23 - Liquid (III): https://codepen.io/alvaromontoro/pen/...
00:28 - Switch: https://codepen.io/alvaromontoro/pen/...
00:33 - Light/Dark: https://codepen.io/alvaromontoro/pen/...
00:40 - On/Off: https://codepen.io/alvaromontoro/pen/...
00:47 - Rebound: https://codepen.io/alvaromontoro/pen/...
00:53 - Liquid (II): https://codepen.io/alvaromontoro/pen/...
01:04 - Wooden (I): https://codepen.io/alvaromontoro/pen/...
Many of these are not my original design. Check the source code for links referencing other author's work and designs.