JSFiddle - React, Tailwind, and code Playground

by Su YangCheng

HTML

<div class="button clickable">
    <input class="toggle" type="checkbox">
    <div class="anim"></div><span>Click!</span>
</div>
<div class="button hoverable">
    <div class="anim"></div><span>Hover!</span>
</div>

SCSS

.button {
    margin: 1em;
    padding: 1em 1.25em;
    text-align: center;
    width: 200px;
    border-radius: 5px;
    overflow: hidden;
    position: relative;
    z-index: 0;
    cursor: pointer;
    -moz-transition: all 0.1s;
    -o-transition: all 0.1s;
    -webkit-transition: all 0.1s;
    transition: all 0.1s;
    background: #0c84e4;
    box-shadow: 0px 1px 1px #085a9b;
    &:active {
        background: #0c7dd8;
        box-shadow: 0px 1px 1px #063e6b;
    }
    span {
        font-weight: 400;
    }
    input[type="checkbox"].toggle {
        -moz-appearance: none;
        -moz-appearance: checkbox-container;
        -webkit-appearance: none;
        position: absolute;
        width: 100%;
        height: 100%;
        margin: 0;
        left: 0;
        top: 0;
        cursor: pointer;
        background-color: transparent;
        &:focus {
            outline: 0; // Get rid of Chrome's ugly outline on focus
        }
    }
    .anim {
        -moz-transform: translateY(-50%) translateX(-50%);
        -ms-transform: translateY(-50%) translateX(-50%);
        -webkit-transform: translateY(-50%) translateX(-50%);
        transform: translateY(-50%) translateX(-50%);
        position: absolute;
        top: 50%;
        left: 50%;
        z-index: -1;
        &:before {
            position: relative;
            content: '';
            display: block;
            margin-top: 100%;
        }
        &:after {
            content: '';
            position: absolute;
            top: 0;
            bottom: 0;
            left: 0;
            right: 0;
            border-radius: 50%;
        }
    }
}

.clickable {
    .toggle:checked + .anim {
        -moz-animation: anim-in 0.75s;
        -webkit-animation: anim-in 0.75s;
        animation: anim-in 0.75s;
        &:after {
            -moz-animation: anim-in-pseudo 0.75s;
            -webkit-animation: anim-in-pseudo 0.75s;
            animation: anim-in-pseudo 0.75s;
        }
    }
   ...