<button class="pc-cut" type="button">Shop now</button>About this button
A tech-style button whose clipped corners are driven by a registered custom property, so the cut deepens smoothly on hover.
How it works
A clip-path polygon cuts the top left and bottom right corners using a custom property, --pc-cut. Because --pc-cut is registered with @property as a length, the browser can animate it, so on hover the cut deepens from 12px to 24px smoothly and the background changes colour at the same time.
Ways to customise it
- Change the 12px and 24px cut sizes.
- Change #ffd166 and #fff for other button colours.
- Move the cut to the other corners by editing the polygon points.
Good to know
clip-path also clips the focus outline, which is why the focus state uses an inset box-shadow instead. Animating a registered custom property works in current browsers, and older ones just snap to the new shape.
Open an example, copy the HTML and the CSS, and paste them into your page. There is nothing to install and no JavaScript to load.