Presets

Border draw button

An outline button whose border draws itself in from the corner on hover.

CSSTailwindReactGIFMP4
00.000 / 0.500s
timing
style
content
20 max

npm i motion · the component uses motion/react

How it works

This outline button starts with a faint 1px border (an inset box-shadow in Text color at 20% opacity). On hover a brighter border in Border color grows out of the top-left corner until it frames the whole button.

The bright border lives on a separate frame element, absolutely positioned over the button with the same corner radius. At rest it is clipped away completely with clip-path: inset(0% 100% 100% 0%), which leaves a zero-size visible area at the top-left corner. On hover the clip-path transitions to inset(0% 0% 0% 0%). The visible window expands diagonally toward the bottom-right, so the top and left edges appear first and the corner closes last. Because clip-path is interpolated numerically, the browser can animate it smoothly.

It is a good secondary action next to a filled primary button, or a "Learn more" link on dark marketing pages. Parameters: Label, Border color, Text color, Border width, Corner radius, Duration and Easing. The default expo-out easing makes most of the border appear in the first third of the transition; 0.4 to 0.6s is enough.

The frame has pointer-events: none and aria-hidden, so it never steals clicks. Hover does not exist for keyboard and touch users, so in your stylesheet add :focus-visible next to :hover on the frame rule; that way tabbing to the button draws the same border.

How do I make the border draw from a different corner?

Change the starting clip-path. inset(0% 100% 100% 0%) collapses toward the top-left. Use inset(100% 0% 0% 100%) to start from the bottom-right, or inset(0% 0% 100% 100%) for the top-right. The hover value stays inset(0%) in all cases. For a center-out reveal, use inset(50% 50% 50% 50%).

Can I draw each side one after another?

Not with a single clip-path. For a sequential four-sided draw you need four line elements (or pseudo-elements) that each scale from 0 to 1 along their own axis, with increasing transition delays. That costs more markup, which is why this preset uses one frame and a diagonal reveal.

Why is there a faint border before hover?

Without it, an outline button with a transparent background would just look like text and users would not recognize it as a button. The 20% inset shadow gives a resting outline. It uses box-shadow instead of border so it does not add to the button size and the frame overlays it exactly.

relatedMore like this

all buttons →
01 Loading button loop
02 Shine sweep button loop
03 Pulse glow button loop
04 3D press button press
05 Gradient shift button loop

Export

format
height

480p max · small watermark · 3 per day · remove limits