Creating engaging and user-friendly interfaces is crucial in web and app development. Toggle switches, though simple, play a significant role in enhancing user experience by providing an intuitive way to control settings. However, finding the perfect toggle design that is both functional and aesthetically pleasing can be a challenge for developers. This article addresses the problem by showcasing 12 creative examples with code.
Is this you? As a journalist, you can create a free Muck Rack account to customize your profile, list your contact preferences, and upload a portfolio of your best work.
Claim your profile
Articles by Jon Kantner
12 Awesome Toggle Switch Designs (With Source Code!) π¨π
30Β minutes ago hackernoon.com Finding the perfect toggle design can be a challenge. This article addresses the problem by showcasing 12 creative examples with code. Creating engaging and user-friendly interfaces is crucial in web and app development. Toggle switches, though simple, play a significant role in enhancing user experience by providing an intuitive way to control settings.
8 CSS & JavaScript Snippets That Feature Wood Textures
Wood textures are perfect for achieving an earthy look. And just like their natural counterparts, there is a wide range of variations to choose from. Consider the nearly endless array of colors and grain patterns. They provide us with plenty of room for customization. In addition, we can even go beyond what we see in nature. But wood is more than just a background player. Designers are using also using it front and center in their presentations. Wooden objects can be the star of the show.
8 CSS & JavaScript Snippets That Feature Wood Textures
Wood textures are perfect for achieving an earthy look. And just like their natural counterparts, there is a wide range of variations to choose from. Consider the nearly endless array of colors and grain patterns. They provide us with plenty of room for customization. In addition, we can even go beyond what we see in nature. But wood is more than just a background player. Designers are using also using it front and center in their presentations. Wooden objects can be the star of the show.
8 Black & White CSS & JavaScript Snippets That Make a Bold Statement
There’s nothing simpler than a black-and-white color scheme. And yet these fiercely contrasting colors may form the most powerful of combinations. For starters, it’s infinitely useful. Using black text on a white background provides the ultimate in accessibility. It’s always a safe bet when designing content. But it goes beyond mere utility. Black and white can also be used to make a bold artistic statement. It’s perfect when crafting those can’t-miss elements on a website or mobile app.
Awesome Demos Roundup #23
The latest compilation of innovative and captivating demos and code experiments from the web.
8 Tasty CSS & JavaScript Snippets for Recreating Sweet Treats
The great thing about a sweet treat is that we don’t need a reason to have one. It doesn’t have to be a birthday or holiday to indulge in candy, baked goods, or even a soft drink. Not that any of us would go overboard, mind you. Kidding aside, these tasty concoctions are often associated with good times. They bring back childhood memories and moments shared with loved ones. And the experience of making them can also spark those warm fuzzy feelings.
8 CSS Snippets for Styling HTML Checkboxes & Radio Buttons
HTML form elements such as checkboxes and radio buttons are staples of the web. But for many years, web designers didn’t do a whole lot to enhance them. That has changed quite a bit in recent times. Thanks to the power of CSS (and the occasional bit of JavaScript), these elements are being put to some seriously creative uses. In some instances, they’re dressed up to the point of being unrecognizable. Finally, their outstanding utility now has looks to match.
That Time I Tried Browsing the Web Without CSS
CSS is what gives every website its design. Websites sure aren’t very fun and friendly without it! I’ve read about somebody going a week without JavaScript and how the experience resulted in websites that were faster, though certain aspects of them would not function as expected. But CSS. Turning off CSS while browsing the web wouldn’t exactly make the web far less usable... right? Or, like JavaScript, would some features not work as expected?
Rotating Windows XP Sound Icon
*, *:before, *:after { border: 0; box-sizing: border-box; margin: 0; padding: 0; } :root { font-size: 10px; --dur: 3s; --waveDel: 0.15s; --dgy: #3f3f3f; --gy: #5d5d5d; --lgy: #ccc; --w: #fff; --pl: #4b4e7b; --pw: #8386be; --lpw: #ced0fa; } body { background-color: #efe9db; font-size: 1em; overflow: hidden; } .speaker, .speaker div { position: absolute; } .speaker { top: 50%; left: 50%; width: 24em; height: 32em; transform: translate(-50%,-50%); } .speaker-back { animation: speakerBackRotate...
Emoji Tornado
window.requestAnimFrame = (function(){ return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function(callback){ window.setTimeout(callback, 1000 / 30); }; })(); window.addEventListener("load",app); function app() { var C = document.getElementsByTagName("canvas")[0], c = C.getContext("2d"), W = 960, H = 640, s = 2; // set canvas dimensions with scale C.width = W * s;...
Balloon Cat
*, *:before, *:after { border: 0; box-sizing: border-box; margin: 0; padding: 0; } :root { font-size: 16px; --catDur: 0.5s; --cloudDur: 1s; } body { background: hsl(199,82.5%,17.6%); font: 1em "Helvetica Neue", Helvetica, sans-serif; line-height: 1.5; } main { background: hsl(199,82.5%,77.6%); margin: 1.5em auto 0 auto; overflow: hidden; position: relative; width: 40em; height: 40em; } .cat, .cat div, .cloud { position: absolute; } .cat, .cat div { transform-style: preserve-3d; } .cat { top:...
Line Belt Illusion
About External Resources You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself. If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying. You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it.
3D-ish Hamburger Menu
*, *:before, *:after { border: 0; box-sizing: border-box; margin: 0; padding: 0; } :root { font-size: 20px; } body { background: hsl(60,100%,90%); color: hsl(0,0%,9%); line-height: 1.5; } nav { $bun: hsl(40,100%,45%); $bunInner: hsl(40,100%,75%); $ketchup: hsl(0,100%,40%); $ketchupT: hsla(0,100%,40%,0); $ketchupLt: hsl(0,100%,80%); $ketchupLtT: hsla(0,100%,80%,0); $ketchupSh: hsl(0,100%,25%); $burger: hsl(0,40%,30%); $cheese: hsl(50,100%,50%); $cheeseLt: hsl(50,100%,75%); $cheeseLtT:...
Role-Swapped Space Invaders
window.requestAnimFrame = (function(){ return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function(callback){ window.setTimeout(callback, 1000 / 60); }; })(); window.addEventListener("DOMContentLoaded",app); function app() { var I = document.querySelector("#intro"), P = document.querySelector("#play"), S = document.querySelector("#stats"), BL =...
Vintage Analog TV
* { border: 0; box-sizing: border-box; margin: 0; padding: 0; } body { background: #cbb; height: 100vh; } main { font-size: 10px; margin: auto; width: 51em; height: 52.5em; } img, canvas { display: block; top: 50%; left: 50%; transform: translate(-50%,-50%); } img { width: 32em; height: 22em; } body, .tv-body, .controls, .legs { display: flex; } .tv-body, .controls { justify-content: center; } .tv-body { background-color: #8c5b3d; background-image: radial-gradient(10em 0.4em at 8em...
Pikachu Emoji
*, *:before, *:after { border: 0; box-sizing: border-box; margin: 0; padding: 0; } body { background: #ffb; padding-top: 1.5em; text-align: center; } .pikachu { display: inline-block; font-size: 100px; position: relative; vertical-align: top; line-height: 1.5; height: 1.5em; width: 1em; } .pikachu:before, .pikachu:after { display: inline-block; line-height: 0.25; letter-spacing: 0; position: absolute; top: 0; left: 0; padding-top: 0.5em; text-align: center; width: 100%; height: 100%;...
Non-Generative CSS Fire
*, *:before, *:after { border: 0; box-sizing: border-box; margin: 0; padding: 0; } :root { --dur: 1s; --delay: -0s; --state: running; --startColor: #dc0; --endColor: #c50; } body { background: #171717; } .fire { /*-webkit-filter: blur(1px); filter: blur(1px);*/ font-size: 60px; margin: 1.5rem auto 0 auto; /* outline: 1px solid #ff0; */ position: relative; width: 2em; height: 5.5em; } .fire div { position: absolute; top: 0; left: 0; will-change: transform; } /* Part A */ .a { animation: a...
Dog is Long
*, *:before, *:after { border: 0; box-sizing: border-box; margin: 0; padding: 0; } :root { --dur: 0.7s; --dogWidth: 15em; --dogUpAngle: -30deg; --dogBounceDown: 2deg; --dogBounceUp: -1deg; /* dog colors */ --w: #fff; --lgy: #404040; --gy: #373737; --dgy: #303030; --bk: #171717; --bn: #e08c66; --bnT: #e08c6600; --dbn: #c06a44; --dbnT: #c06a4400; --pk: #ff7f7f; --hpk: #cc5f5f; } body, header, footer { display: flex; } body { background-image: linear-gradient( #acc calc(50% - 2em), #fff calc(50%...
Deposit Slip
* { border: 0; box-sizing: border-box; margin: 0; padding: 0; } body, input { color: #242424; font-size: calc(20px + (30 - 20) * (100vw - 480px) / (1136 - 480)); line-height: 1; } body { background-color: #555; font-family: Helvetica, sans-serif; overflow-x: hidden; } button, input[type=checkbox] { position: fixed; } button { background: #5785f6; border-radius: 0.25em; color: #fff; cursor: pointer; font-size: inherit; font-weight: 700; margin: auto; padding: 0.375em 0.75em; top: 0.75em; left:...
Converting Color Spaces in JavaScript | CSS-Tricks
A challenge I faced in building an image “emojifier” was that I needed to change the color spaces of values obtained using getImageData() from RGB to HSL. I used arrays of emojis arranged by brightness and saturation, and they were HSL-based for the best matches of average pixel colors with the emojis. In this article, we’ll study functions that will be useful for converting both opaque and alpha-enabled color values. Modern browsers currently support the color spaces RGB(A), hex, and HSL(A).
Flipping Out
*, *:before, *:after { border: 0; box-sizing: border-box; margin: 0; padding: 0; } :root { --dur: 1s; } body { font: 24px "Helvetica Neue", Helvetica, sans-serif; line-height: 1; } main { margin: 3em auto 0; width: 20.5em; } div, span { /* outline: 1px solid red; */ } div { margin-bottom: 2em; } span { display: inline-block; } /* Emoticon parts */ .a-arm { animation: a-armMove var(--dur) linear infinite; transform-origin: 25% 25%; } .a-trajectory { animation: a-trajectory var(--dur) linear...
Sad Mac 404 Error Page
* { border: 0; box-sizing: border-box; margin: 0; padding: 0; } body { background: currentColor; } /* I.
The Gift That Keeps On Giving
$sqSize: 12px; $contW: 360px; $contH: 360px; $xSpaces: 16; $ySpaces: 16; $zSpaces: 16; $xAngle: 45deg; $zAngle: 45deg; $animParams: 4s ease-out infinite; // * Colors * $y: #ff4; $r: #f44; // * Block placement * // parameters: x-pos,y-pos,z-pos, width,depth,height, color $blocks: // box (2,2,1, 14,14,12, $y) // lid (1,1,10.1, 16,16,3, $y) // bow (6,8,13, 2,2,2, $r) (8,10,13, 2,2,2, $r) (8,8,13, 2,2,1, $r) (10,8,13, 2,2,2, $r) (8,6,13, 2,2,2, $r) // smaller box (7.25,7.25,1, 3.5,3.5,3, $y) //...
Rudolph
// colors $lbr: #b95948; $br: #973726; $dbr: #33130c; $tn: #db84ad; $bk: #111; $pk: #cd8f8b; $w: #f0f0e0; $gy: #222; $r: #c00; // animation parameters $dur: 1.2s; $timing: linear; * { border: 0; box-sizing: border-box; margin: 0; padding: 0; } body { background: #6a7dd0; font-size: 10px; overflow-x: hidden; height: 100vh; } .rudolph { //outline: 1px solid $w; top: 50%; left: 50%; transform: translate(-50%,-50%); width: 25em; height: 25em; &, div { //animation-play-state: paused; position:...
Fitbit Alta HR
window.addEventListener("load",ui); function ui() { var cnv = document.getElementsByTagName("canvas")[0], ct = cnv.getContext("2d"), // scale pixel size (meant for zooming) p = 1, // canvas dimensions w = 36 * p, h = 128 * p, s = 2; cnv.width = w * s; cnv.height = h * s; cnv.style.width = w + "px"; cnv.style.height = h + "px"; ct.scale(s,s); var itemDetails = document.getElementById("item-details"), digits = [ [ [0,0,0,0,0,1,1,1,1,1,0,0,0,0,0], [0,0,0,1,1,1,1,1,1,1,1,1,0,0,0],...
Naturalized Checkbox Toggle Switches
css Audio - Active file-generic CSS - Active Generic - Active HTML - Active Image - Active JS - Active SVG - Active Text - Active file-generic Video - Active Love html icon-new-collection icon-person icon-team log-out octocat pop-out spinnerstar tv Pen Settings HTML CSS JavaScript Behavior JavaScript Preprocessor About JavaScript Preprocessors JavaScript preprocessors can help make authoring JavaScript easier and more convenient.
Input Idea: type="plane"
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself. If the stylesheet you link to has the file extension of a preprocessor, we'll attempt to process it before applying. You can also link to another Pen here, and we'll pull the CSS from that Pen and include it.
Dump Truck Loading Animation
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself. If the stylesheet you link to has the file extension of a preprocessor, we'll attempt to process it before applying. You can also link to another Pen here, and we'll pull the CSS from that Pen and include it.
Wheel of Fortune
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself. If the stylesheet you link to has the file extension of a preprocessor, we'll attempt to process it before applying. You can also link to another Pen here, and we'll pull the CSS from that Pen and include it.
2D Lighthouse Rotation
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself. If the stylesheet you link to has the file extension of a preprocessor, we'll attempt to process it before applying. You can also link to another Pen here, and we'll pull the CSS from that Pen and include it.
Brick Phone
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself. If the stylesheet you link to has the file extension of a preprocessor, we'll attempt to process it before applying. You can also link to another Pen here, and we'll pull the CSS from that Pen and include it.
408 Timeout
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself. If the stylesheet you link to has the file extension of a preprocessor, we'll attempt to process it before applying. You can also link to another Pen here, and we'll pull the CSS from that Pen and include it.
403 Error
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself. If the stylesheet you link to has the file extension of a preprocessor, we'll attempt to process it before applying. You can also link to another Pen here, and we'll pull the CSS from that Pen and include it.
Nerves
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself. If the stylesheet you link to has the file extension of a preprocessor, we'll attempt to process it before applying. You can also link to another Pen here, and we'll pull the CSS from that Pen and include it.
The Faces of Electric Outlets
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself. If the stylesheet you link to has the file extension of a preprocessor, we'll attempt to process it before applying. You can also link to another Pen here, and we'll pull the CSS from that Pen and include it.
Pencil and Paper Checkboxes
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself. If the stylesheet you link to has the file extension of a preprocessor, we'll attempt to process it before applying. You can also link to another Pen here, and we'll pull the CSS from that Pen and include it.
Image Emojifier
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself. If the stylesheet you link to has the file extension of a preprocessor, we'll attempt to process it before applying. You can also link to another Pen here, and we'll pull the CSS from that Pen and include it.
Charlotte’s World Wide Web
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself. If the stylesheet you link to has the file extension of a preprocessor, we'll attempt to process it before applying. You can also link to another Pen here, and we'll pull the CSS from that Pen and include it.
Tire Toggle
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself. If the stylesheet you link to has the file extension of a preprocessor, we'll attempt to process it before applying. You can also link to another Pen here, and we'll pull the CSS from that Pen and include it.
Isometric iPhones
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself. If the stylesheet you link to has the file extension of a preprocessor, we'll attempt to process it before applying. You can also link to another Pen here, and we'll pull the CSS from that Pen and include it.
Wavy Napkin Illusion
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself. If the stylesheet you link to has the file extension of a preprocessor, we'll attempt to process it before applying. You can also link to another Pen here, and we'll pull the CSS from that Pen and include it.
Tweet Sending Morph Animation
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself. If the stylesheet you link to has the file extension of a preprocessor, we'll attempt to process it before applying. You can also link to another Pen here, and we'll pull the CSS from that Pen and include it.
Orbital Menu
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself. If the stylesheet you link to has the file extension of a preprocessor, we'll attempt to process it before applying. You can also link to another Pen here, and we'll pull the CSS from that Pen and include it.
Blocky US Flag
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself. If the stylesheet you link to has the file extension of a preprocessor, we'll attempt to process it before applying. You can also link to another Pen here, and we'll pull the CSS from that Pen and include it.
Blocky Diesel
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself. If the stylesheet you link to has the file extension of a preprocessor, we'll attempt to process it before applying. You can also link to another Pen here, and we'll pull the CSS from that Pen and include it.
Drawing Images with CSS Gradients
What I mean by "CSS images" is images that are created using only HTML elements and CSS. They look as if they were SVGs drawn in Adobe Illustrator but they were made right in the browser. Some techniques I’ve seen used are tinkering with border radii, box shadows, and sometimes . You can find a lot of great examples if you search daily css images" on CodePen. I drew some myself, including this Infinity Gauntlet, but in one element with only backgrounds and minimal use of other properties.
Cloud Download Animation
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself. If the stylesheet you link to has the file extension of a preprocessor, we'll attempt to process it before applying. You can also link to another Pen here, and we'll pull the CSS from that Pen and include it.
CSS Blend Mode Fire
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself. If the stylesheet you link to has the file extension of a preprocessor, we'll attempt to process it before applying. You can also link to another Pen here, and we'll pull the CSS from that Pen and include it.
Cold-Hot Toggle Switch
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself. If the stylesheet you link to has the file extension of a preprocessor, we'll attempt to process it before applying. You can also link to another Pen here, and we'll pull the CSS from that Pen and include it.
Show More
loading
Actions
Is this you?
As a journalist, you can create a free Muck Rack account to customize your profile, list your contact preferences, and upload a portfolio of your best work.Get in touch with Jon
Contact Jon, search articles and posts on X, monitor coverage, and track replies from one place.
Learn more about Muck Rack