Sat Jul 16 2022

Button with Amzaing Icons Effect

CSS5217 views

File Name: amazing-send-button-with-icon-effect.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Amazing Send Button with Icon Effect</title>
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=Raleway:wght@500&display=swap" rel="stylesheet">
    <style>
        * {
            margin: 0;
            padding: 0;
            font-family: 'Raleway', sans-serif;
        }

        body { background-color: #292929; }

        section {
            display: flex;
            justify-content: center;
            align-items: center;
            width: 100%;
            height: 100vh;
        }

        button#btn {
            background-color: #1b8bf9;
            border: none;
            border-radius: 5px;
            padding: 15px 70px 15px 40px;
            color: #fff;
            font-size: 20px;
            font-weight: 500;
            text-transform: uppercase;
            cursor: pointer;
            overflow: hidden;
            position: relative;
            box-shadow: 1px 2.9px 16px rgba(27,139,249,0.4);
        }

        button#btn.active {
            box-shadow: 1px 2.9px 16px rgba(39,174,96,0.4);
        }
        

        button#btn span {
            position: absolute;
            top: 0;
            bottom: 0;
            right: 0;
            display: flex;
            justify-content: center;
            align-items: center;
            transition: 0.2s all cubic-bezier(0.31,-0.105,0.43,1.4);
        }

        button#btn span svg {
            width: 25px;
            height: 25px;
        }

        button#btn span.arrow {
            width: 50px;
            background-color: #1b8bf9;
        }

        button#btn.active span.arrow,
        button#btn:hover span.arrow {
            width: 100%;
        }

        button#btn span.done {
            left: 0;
            background-color: #27ae60;
            opacity: 0;
            visibility: hidden;
        }

        button#btn.active span.done {
            opacity: 1;
            visibility: visible;
        }
    </style>

    <script>
        function send() {
            let btn = document.getElementById('btn');
            btn.classList.add('active');

            setTimeout(function () {
                btn.classList.remove('active')
            }, 3000)
        }
    </script>
    
</head>
<body>
    <section>
        <button onclick="send()" id="btn">
            Send
            <span class="arrow">
                <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
                    <path stroke-linecap="round" stroke-linejoin="round" d="M9 5l7 7-7 7" />
                </svg>
            </span>
            <span class="done">
                <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
                    <path stroke-linecap="round" stroke-linejoin="round" d="M5 13l4 4L19 7" />
                </svg>
            </span>
        </button>
    </section>
</body>
</html>

Result Screenshot(s)

Button with Amzaing Icons EffectWorking Sample0

We use cookies to improve your experience on our site and to show you personalised advertising. Please read our cookie policy and privacy policy.