Material Buttons

Developer
Size
5,794 Kb
Views
22,264

How do I make an material buttons?

Another 'Material Design' set of buttons to add the plethora of choices already out there. I made it so you can choose to 'materialize' it with a javascript function, all you do is pass in the click event and the button element to the function and it will work its magic. Also built without needing jQuery because why not.. What is a material buttons? How do you make a material buttons? This script and codes were developed by Blake Tarter on 26 September 2022, Monday.

Material Buttons Previews

Material Buttons - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Material Buttons</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css"> <style> /* NOTE: The styles were added inline because Prefixfree needs access to your styles and they must be inlined if they are on local disk! */ .material { height: 50px; padding: 0 50px; font-size: 18px; text-decoration: none; color: #ffffff; border-radius: 1px; background-color: #2196f3; border: none; -webkit-box-shadow: 0px 3px 3px 0px rgba(50, 50, 50, 0.1); -moz-box-shadow: 0px 3px 3px 0px rgba(50, 50, 50, 0.1); box-shadow: 0px 3px 3px 0px rgba(50, 50, 50, 0.1); margin: 25px 0; display: inline-block; line-height: 50px; text-align: center; overflow: hidden; position: relative; font-family: 'Roboto', 'Helvetica', 'Arial', 'Sans Serif'; box-sizing: border-box; -webkit-transition: 0.3s ease; transition: 0.3s ease;
}
.material.full { width: 100%;
}
.material.sm { width: 150px;
}
.material.md { width: 200px;
}
.material.lg { width: 300px;
}
.material .ink { position: absolute; border-radius: 50%; height: 1px; width: 1px; border: 1px solid rgba(13, 71, 161, 0.8); -webkit-transform: translate(-50%, -50%); transform: translate(-50%, -50%); pointer-events: none; opacity: 0.8; box-sizing: border-box; -webkit-transition: 0.3s ease; transition: 0.3s ease;
}
.material:active, .material:focus { background-color: #1976d2; -webkit-box-shadow: 0px 4px 3px 0px rgba(50, 50, 50, 0.2); -moz-box-shadow: 0px 4px 3px 0px rgba(50, 50, 50, 0.2); box-shadow: 0px 4px 3px 0px rgba(50, 50, 50, 0.2); outline: 0; -webkit-transition: 0.3s ease; transition: 0.3s ease;
}
.material:hover { background-color: #1669bb; -webkit-box-shadow: 0px 5px 3px 0px rgba(50, 50, 50, 0.3); -moz-box-shadow: 0px 5px 3px 0px rgba(50, 50, 50, 0.3); box-shadow: 0px 5px 3px 0px rgba(50, 50, 50, 0.3); cursor: pointer; -webkit-transition: 0.3s ease; transition: 0.3s ease;
}
.material.yellow { background-color: #ffeb3b; color: #333333;
}
.material.yellow.ghost { color: #ffeb3b;
}
.material.yellow .ink { border-color: rgba(245, 127, 23, 0.8);
}
.material.yellow:active, .material.yellow:focus { background-color: #fbc02d;
}
.material.yellow:hover { background-color: #fbb814;
}
.material.teal { background-color: #009688; color: white;
}
.material.teal.ghost { color: #009688;
}
.material.teal .ink { border-color: rgba(0, 77, 64, 0.8);
}
.material.teal:active, .material.teal:focus { background-color: #00796b;
}
.material.teal:hover { background-color: #006054;
}
.material.red { background-color: #f44336; color: #ffffff;
}
.material.red.ghost { color: #f44336;
}
.material.red .ink { border-color: rgba(183, 28, 28, 0.8);
}
.material.red:active, .material.red:focus { background-color: #d32f2f;
}
.material.red:hover { background-color: #c02929;
}
.material.ghost { color: #2196f3; background-color: transparent;
}
.material.ghost:hover, .material.ghost:active, .material.ghost:focus { background-color: transparent;
}
.material.disabled { background-color: #999999; color: #666666; -webkit-box-shadow: 0 0 0 0 transparent; -moz-box-shadow: 0 0 0 0 transparent; box-shadow: 0 0 0 0 transparent;
}
.material.disabled .ink { display: none;
}
.material.disabled:hover, .material.disabled:active, .material.disabled:focus { cursor: initial; background-color: #999999; -webkit-box-shadow: 0 0 0 0 transparent; -moz-box-shadow: 0 0 0 0 transparent; box-shadow: 0 0 0 0 transparent;
}
@media (max-width: 720px) { .material.sm, .material.md, .material.lg { width: 90%; margin-left: auto; margin-right: auto; }
}
/** * Start display styles */
body { color: #333333; text-align: center; background-color: #FAFAFA;
}
.title { color: #2196f3;
}
.desc { width: 60%; margin: 0 auto;
} </style> <script src="https://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js"></script>
</head>
<body> <h1 class="title">Material Buttons</h1>
<h4>By: Blake Tarter</h4>
<p class="desc">Another 'Material Design' set of buttons to add the plethora of choices already out there. I made it so you can choose to 'materialize' it with a javascript function, all you do is pass in the click event and the button element to the function and it will work its magic. Also built without needing jQuery because why not.</p>
<button class="material">Blue</button>
<!-- <button class="material sm">Small</button>
<button class="material md">Medium</button>
<button class="material lg">Large</button> -->
<button class="material ghost">Ghost</button>
<!-- <br /> -->
<button class="material yellow">Yellow</button>
<!-- <button class="material yellow sm">Small</button>
<button class="material yellow md">Medium</button>
<button class="material yellow lg">Large</button> -->
<button class="material yellow ghost">Ghost</button>
<!-- <br /> -->
<button class="material teal">Teal</button>
<!-- <button class="material teal sm">Small</button>
<button class="material teal md">Medium</button>
<button class="material teal lg">Large</button> -->
<button class="material teal ghost">Ghost</button>
<!-- <br /> -->
<button class="material red">Red</button>
<!-- <button class="material red sm">Small</button>
<button class="material red md">Medium</button>
<button class="material red lg">Large</button> -->
<button class="material red ghost">Ghost</button>
<br />
<button class="material disabled">Disabled</button> <script src="js/index.js"></script>
</body>
</html>

Material Buttons - Script Codes CSS Codes

.material { height: 50px; padding: 0 50px; font-size: 18px; text-decoration: none; color: #ffffff; border-radius: 1px; background-color: #2196f3; border: none; -webkit-box-shadow: 0px 3px 3px 0px rgba(50, 50, 50, 0.1); -moz-box-shadow: 0px 3px 3px 0px rgba(50, 50, 50, 0.1); box-shadow: 0px 3px 3px 0px rgba(50, 50, 50, 0.1); margin: 25px 0; display: inline-block; line-height: 50px; text-align: center; overflow: hidden; position: relative; font-family: 'Roboto', 'Helvetica', 'Arial', 'Sans Serif'; box-sizing: border-box; -webkit-transition: 0.3s ease; transition: 0.3s ease;
}
.material.full { width: 100%;
}
.material.sm { width: 150px;
}
.material.md { width: 200px;
}
.material.lg { width: 300px;
}
.material .ink { position: absolute; border-radius: 50%; height: 1px; width: 1px; border: 1px solid rgba(13, 71, 161, 0.8); -webkit-transform: translate(-50%, -50%); transform: translate(-50%, -50%); pointer-events: none; opacity: 0.8; box-sizing: border-box; -webkit-transition: 0.3s ease; transition: 0.3s ease;
}
.material:active, .material:focus { background-color: #1976d2; -webkit-box-shadow: 0px 4px 3px 0px rgba(50, 50, 50, 0.2); -moz-box-shadow: 0px 4px 3px 0px rgba(50, 50, 50, 0.2); box-shadow: 0px 4px 3px 0px rgba(50, 50, 50, 0.2); outline: 0; -webkit-transition: 0.3s ease; transition: 0.3s ease;
}
.material:hover { background-color: #1669bb; -webkit-box-shadow: 0px 5px 3px 0px rgba(50, 50, 50, 0.3); -moz-box-shadow: 0px 5px 3px 0px rgba(50, 50, 50, 0.3); box-shadow: 0px 5px 3px 0px rgba(50, 50, 50, 0.3); cursor: pointer; -webkit-transition: 0.3s ease; transition: 0.3s ease;
}
.material.yellow { background-color: #ffeb3b; color: #333333;
}
.material.yellow.ghost { color: #ffeb3b;
}
.material.yellow .ink { border-color: rgba(245, 127, 23, 0.8);
}
.material.yellow:active, .material.yellow:focus { background-color: #fbc02d;
}
.material.yellow:hover { background-color: #fbb814;
}
.material.teal { background-color: #009688; color: white;
}
.material.teal.ghost { color: #009688;
}
.material.teal .ink { border-color: rgba(0, 77, 64, 0.8);
}
.material.teal:active, .material.teal:focus { background-color: #00796b;
}
.material.teal:hover { background-color: #006054;
}
.material.red { background-color: #f44336; color: #ffffff;
}
.material.red.ghost { color: #f44336;
}
.material.red .ink { border-color: rgba(183, 28, 28, 0.8);
}
.material.red:active, .material.red:focus { background-color: #d32f2f;
}
.material.red:hover { background-color: #c02929;
}
.material.ghost { color: #2196f3; background-color: transparent;
}
.material.ghost:hover, .material.ghost:active, .material.ghost:focus { background-color: transparent;
}
.material.disabled { background-color: #999999; color: #666666; -webkit-box-shadow: 0 0 0 0 transparent; -moz-box-shadow: 0 0 0 0 transparent; box-shadow: 0 0 0 0 transparent;
}
.material.disabled .ink { display: none;
}
.material.disabled:hover, .material.disabled:active, .material.disabled:focus { cursor: initial; background-color: #999999; -webkit-box-shadow: 0 0 0 0 transparent; -moz-box-shadow: 0 0 0 0 transparent; box-shadow: 0 0 0 0 transparent;
}
@media (max-width: 720px) { .material.sm, .material.md, .material.lg { width: 90%; margin-left: auto; margin-right: auto; }
}
/** * Start display styles */
body { color: #333333; text-align: center; background-color: #FAFAFA;
}
.title { color: #2196f3;
}
.desc { width: 60%; margin: 0 auto;
}

Material Buttons - Script Codes JS Codes

/** * Materialze made by Blake Tarter * Do whatever you want with it. */
function materialize(e, button) { if (!e || !button) { console.error('Failed to materialize, you need to pass the click event and the element.'); return; } var x = e.offsetX, y = e.offsetY, ink = document.createElement('div'), baseStyle = 'top: ' + y + 'px; left: ' + x + 'px; ', widthStyle = 'border-width: ' + button.offsetWidth / 1 + 'px; '; function createInk() { ink.className = 'ink'; ink.setAttribute('style', baseStyle); button.appendChild(ink); requestAnimationFrame(animateToWidth); } function animateToWidth() { ink.setAttribute('style', baseStyle + widthStyle); } function startToFade() { ink.setAttribute('style', baseStyle + widthStyle + 'opacity: 0;'); } function removeInk() { button.removeChild(ink); } requestAnimationFrame(createInk); setTimeout(function() { requestAnimationFrame(startToFade); }, 350); setTimeout(function() { requestAnimationFrame(removeInk); }, 650);
}
window.onload = function() { var materialButtons = document.getElementsByClassName('material'), i, l; for (i = 0, l = materialButtons.length; i < l; i++) { materialButtons[i].addEventListener('click', function(e) { materialize(e, e.target); }); }
}
Material Buttons - Script Codes
Material Buttons - Script Codes
Home Page Home
Developer Blake Tarter
Username blaketarter
Uploaded September 26, 2022
Rating 4
Size 5,794 Kb
Views 22,264
Do you need developer help for Material Buttons?

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!

Blake Tarter (blaketarter) Script Codes
Create amazing web 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!