<button class="btn--wipe"><span class="btn__inner">Wipe left to right</span></button>

<button class="btn--wipe btn--wipe-vertical"><span class="btn__inner">Wipe top to bottom</span></button>
/**
 * Button wipe with pseudo-elements
 */


.btn--wipe {
    --bg-color: thistle;
    --bg-color-hover: darkorange;
    --duration: 300ms;
    --easing: cubic-bezier(0.165, 0.840, 0.440, 1);
    --padding-x: 1.5rem;
    --padding-y: 1rem;
    
    background-color: var(--bg-color);
    color: black;
    display: inline-block;
    line-height: 1;
    position: relative;
}

.btn--wipe::before {
    background-color: var(--bg-color-hover);
    content: '';
    height: 100%;
    left: 0;
    position: absolute;
    top: 0;
    transform: scaleX(0);
    transform-origin: 0 0;
    transition: transform var(--duration) var(--easing);
    width: 100%;
}

.btn--wipe .btn__inner {
    display: block;
    padding: var(--padding-y) var(--padding-x);
    position: relative;
}

.btn--wipe:hover::before {
    transform: scaleX(1);
}


/* btn--wipe-vertical */

.btn--wipe-vertical::before {
    transform: scaleY(0);
}



/**
 * demo styles
 */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: ghostwhite;
    font-family: system-ui, -apple-system, sans-serif;
    padding: 1rem;
}

button {
    border: 0;
    cursor: pointer;
    font-family: system-ui, -apple-system, sans-serif;
    font-weight: 600;
}
View Compiled

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.