Switch from Google Material Design

Developer
Size
4,911 Kb
Views
16,192

How do I make an switch from google material design?

What is a switch from google material design? How do you make a switch from google material design? This script and codes were developed by Sergey on 14 November 2022, Monday.

Switch from Google Material Design Previews

Switch from Google Material Design - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Switch from Google Material Design </title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css"> <link rel='stylesheet prefetch' href='http://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/themes/smoothness/jquery-ui.css'> <link rel="stylesheet" href="css/style.css">
</head>
<body>
<div class="wrapper"> <div class="ripple"></div> <div class="content"> <p class="header">Material design switch</p> <ul> <li> <p>Some Option 1</p> <input id="test" type="checkbox" hidden="hidden"/> <label class="switch" for="test"></label> </li> <li> <p>Some Option 2</p> <input id="test1" type="checkbox" hidden="hidden"/> <label class="switch" for="test1"></label> </li> <li> <p>Some Option 3</p> <input id="test2" type="checkbox" hidden="hidden"/> <label class="switch" for="test2"></label> </li> </ul> </div> <div class="footer"> <button class="button theme" type="button">Switch Theme</button> </div>
</div> <script src="js/index.js"></script>
</body>
</html>

Switch from Google Material Design - Script Codes CSS Codes

@import url("https://fonts.googleapis.com/css?family=Roboto");
body { background: #eee; font: normal normal normal 1rem/1 'Roboto'; color: #808080;
}
.wrapper { display: table; position: absolute; top: 0; left: 0; right: 0; bottom: 0; width: 17.5rem; padding: 0; background: #fff; border-radius: 0.125rem; text-align: right; margin: auto; box-shadow: 0 1rem 2.5rem rgba(0,0,0,0.3), 0 0.75rem 0.75rem rgba(0,0,0,0.22); overflow: hidden; z-index: 100;
}
.wrapper .content { padding: 1.5rem 1.5rem 1rem;
}
.wrapper .footer { padding: 0 1rem 0.5rem;
}
.wrapper .ripple { display: block; position: absolute; width: 4px; height: 4px; top: 100%; left: 100%; border-radius: 100%; -webkit-transition: box-shadow 0.56s cubic-bezier(0.4, 0, 0.2, 1); transition: box-shadow 0.56s cubic-bezier(0.4, 0, 0.2, 1); z-index: -1; will-change: transform;
}
.wrapper .header { display: block; font-size: 1.25rem; text-align: left; color: rgba(0,0,0,0.84); margin: 0; padding: 0; -webkit-transition: color 0.56s cubic-bezier(0.4, 0, 0.2, 1); transition: color 0.56s cubic-bezier(0.4, 0, 0.2, 1);
}
.wrapper ul { display: block; padding: 0; width: 100%;
}
.wrapper ul li { display: block; padding: 1rem 0 0;
}
.wrapper ul li p { display: inline-block; line-height: 1.5rem; margin: 0 1.25rem 0; vertical-align: middle; -webkit-transition: color 0.56s cubic-bezier(0.4, 0, 0.2, 1); transition: color 0.56s cubic-bezier(0.4, 0, 0.2, 1);
}
.wrapper.dark,
.wrapper.dark .header { color: rgba(255,255,255,0.84);
}
.wrapper.dark .ripple,
.wrapper.dark .header .ripple { box-shadow: inset 0 0 0 0.5rem rgba(0,0,0,0.77), 0 0 0 25rem rgba(0,0,0,0.77);
}
.wrapper.dark .button,
.wrapper.dark .header .button { color: rgba(255,255,255,0.84);
}
.wrapper.dark .switch,
.wrapper.dark .header .switch { background: rgba(255,255,255,0.3);
}
.wrapper.dark .switch::before,
.wrapper.dark .header .switch::before { background: #bdbdbd;
}
.wrapper.dark input:checked + .switch,
.wrapper.dark .header input:checked + .switch { background: rgba(128,203,196,0.5);
}
.wrapper.dark input:checked + .switch::before,
.wrapper.dark .header input:checked + .switch::before { background: #80cbc4;
}
.wrapper.dark input:checked + .switch:active::before,
.wrapper.dark .header input:checked + .switch:active::before { box-shadow: 0 0.25rem 0.5rem rgba(0,0,0,0.28), 0 0 0 1.25rem rgba(128,203,196,0.2);
}
.button { display: inline-block; position: relative; padding: 0 0.75rem; height: 2.25rem; border: none; margin: 0.5rem 0; cursor: pointer; border-radius: 2px; font-size: 1rem; text-transform: uppercase; text-decoration: none; color: rgba(0,0,0,0.84); background: none; -webkit-transition: box-shadow 0.28s cubic-bezier(0.4, 0, 0.2, 1), color 0.28s cubic-bezier(0.4, 0, 0.2, 1); transition: box-shadow 0.28s cubic-bezier(0.4, 0, 0.2, 1), color 0.28s cubic-bezier(0.4, 0, 0.2, 1); outline: none;
}
.button:hover { box-shadow: 0 3px 6px rgba(0,0,0,0.2), 0 3px 6px rgba(0,0,0,0.28);
}
.button:active { box-shadow: 0 10px 20px rgba(0,0,0,0.19), 0 6px 6px rgba(0,0,0,0.23);
}
.switch { display: inline-block; position: relative; width: 2.5rem; height: 1rem; border-radius: 0.5rem; background: rgba(0,0,0,0.26); -webkit-transition: background 0.28s cubic-bezier(0.4, 0, 0.2, 1); transition: background 0.28s cubic-bezier(0.4, 0, 0.2, 1); vertical-align: middle; cursor: pointer;
}
.switch::before { content: ''; position: absolute; top: -0.25rem; left: -0.25rem; width: 1.5rem; height: 1.5rem; background: #fafafa; box-shadow: 0 0.25rem 0.5rem rgba(0,0,0,0.28); border-radius: 50%; -webkit-transition: left 0.28s cubic-bezier(0.4, 0, 0.2, 1), background 0.28s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.28s cubic-bezier(0.4, 0, 0.2, 1); transition: left 0.28s cubic-bezier(0.4, 0, 0.2, 1), background 0.28s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}
.switch:active::before { box-shadow: 0 0.25rem 0.5rem rgba(0,0,0,0.28), 0 0 0 1.25rem rgba(128,128,128,0.1);
}
input:checked + .switch { background: rgba(139,195,74,0.5);
}
input:checked + .switch::before { left: 1.25rem; background: #8bc34a;
}
input:checked + .switch:active::before { box-shadow: 0 0.25rem 0.5rem rgba(0,0,0,0.28), 0 0 0 1.25rem rgba(139,195,74,0.2);
}

Switch from Google Material Design - Script Codes JS Codes

'use strict';
var wrapper = document.querySelector('.wrapper');
var button = document.querySelector('.button');
var ripple = document.querySelector('.ripple');
button.addEventListener('click', function (e) { var top = button.offsetTop + e.offsetY; var left = button.offsetLeft + e.offsetX; Object.assign(ripple.style, { top: top + 'px', left: left + 'px' }); wrapper.classList.toggle('dark');
});
Switch from Google Material Design - Script Codes
Switch from Google Material Design - Script Codes
Home Page Home
Developer Sergey
Username JohnTheCat
Uploaded November 14, 2022
Rating 4.5
Size 4,911 Kb
Views 16,192
Do you need developer help for Switch from Google Material Design?

Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!

Sergey (JohnTheCat) Script Codes
Create amazing SEO content with AI!

Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!