JSFiddle - React, Tailwind, and code Playground
by Vadim
HTML
<button class="button" aria-label="Кнопка">Кнопка</button>
<br>
<button class="button" aria-label="Кнопка большая">Кнопка большая</button>
<br>
<button class="button" aria-label="Кнопка большая с переносом текста">Кнопка большая <br/> с переносом текста</button>
CSS
body {
background-color: black;
height: 100vh;
width: 100vw;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.button {
background-image: linear-gradient(to right, red, orange); /* Цвет бордера в данном случае */
color: white;
font-size: 16px;
padding: 10px 20px;
border: none;
clip-path: polygon(0px 0px, calc(100% - 10px) 0px, 100% 10px, 100% 100%, 10px 100%, 0 calc(100% - 10px));
position: relative;
}
.button::after {
content: attr(aria-label);
width: calc(100% - 2px);
height: calc(100% - 2px);
position: absolute;
top: 1px;
left: 1px;
background-color: black; /* Цвет заливки в данном случае */
display: flex;
align-items: center;
justify-content: center;
clip-path: inherit;
transition: all 0.2s ease-in-out;
z-index: 2;
}
.button:hover {
background-image: none;
}
.button:hover::after {
background-color: transparent;
color: white;
}
.button:hover::before {
transform: scaleX(1);
}
.button::before {
content: '';
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
background-image: linear-gradient(to right, red, orange);
z-index: 1;
transform: scaleX(0);
transition: all 0.3s ease-in-out;
transform-origin: left center;
clip-path: inherit;
}