Loading video...

Video Failed to Load

Go Home

This works by using: - normal border-radius - a ::before pseudo-element for the tab - Framer Motion to handle the drag interaction - a tiny distance-to-progress calculation that updates the border radii

309,845 views • 2 months ago •via X (Twitter)

36 Comments

Haz's profile picture
Haz2 months ago

That's cool. I built it a while ago. The biggest challenge is syncing it with nonlinear transitions:

daniel petho's profile picture
daniel petho2 months ago

ufff this is so goooood!

Kevin Grajeda's profile picture
Kevin Grajeda2 months ago

🙌thanks

Said fatah's profile picture
Said fatah2 months ago

recreated it using clip-path , this was a fun exercise for my frontend skills .

Spanky McDoob's profile picture
Spanky McDoob2 months ago

theres a point where it gets too pointy on the slide, i wonder if that can be fixed

Mathieu Jouhet's profile picture
Mathieu Jouhet2 months ago

This reminds me of the technique I used and explain in my how to round svg polygons @observablehq notebook:

Moe Amaya's profile picture
Moe Amaya2 months ago

Sooo good

Mona's profile picture
Mona2 months ago

really cool!

Rasmus Andersson's profile picture
Rasmus Andersson2 months ago

Very nice! Add smoothing to the curves (squircle style) and it’ll look even more organic I bet

Kevin Grajeda's profile picture
Kevin Grajeda2 months ago

Will do!

shawn.'s profile picture
shawn.2 months ago

thank you for this

Igor bedesqui's profile picture
Igor bedesqui2 months ago

amazing post thank you

John Rees's profile picture
John Rees2 months ago

would you mind sharing what you created this animation with? it's so effective for explaining things!

Ashutosh Rana • UX for AI Products's profile picture
Ashutosh Rana • UX for AI Products2 months ago

Preety cool, the amount of details is crazy

Edoardo Galati's profile picture
Edoardo Galati2 months ago

So smooth!

Rakibul's profile picture
Rakibul2 months ago

superb

Rico's profile picture
Rico2 months ago

soo tufff

رِزق's profile picture
رِزق2 months ago

The devil is in the details. 😫

Rene Wang's profile picture
Rene Wang2 months ago

love your attention on details. gonna feature this on

AI Mastery Guide's profile picture
AI Mastery Guide2 months ago

That distance to progress trick is such a clever way to handle the drag.

Wes Winder's profile picture
Wes Winder2 months ago

that's beautiful

Isaiah's profile picture
Isaiah2 months ago

yes thank you so much for the debug view! so cool (:

Nicolas's profile picture
Nicolas2 months ago

Love those details nobody notices, they're what puts the app ahead of competitors.

Avi Ashkenazi's profile picture
Avi Ashkenazi2 months ago

Love the details

Chauve Camille's profile picture
Chauve Camille2 months ago

It's really good. 🔥

meowhib's profile picture
meowhib2 months ago

is there any design reasoning behind why the blue circle is smaller than the red one?

MIKE SUNDAY's profile picture
MIKE SUNDAY2 months ago

I love this.

Said fatah's profile picture
Said fatah2 months ago

sick ! recreating this right now !

Saksham Arora's profile picture
Saksham Arora2 months ago

This is so cool. Thanks for the clear breakdown

猫不困's profile picture
猫不困2 months ago

学到了,大佬 Learned something, expert!

Eerie Pariah's profile picture
Eerie Pariah2 months ago

Nobody will notice this

Alireza Najafi's profile picture
Alireza Najafi2 months ago

Could we have borders around the selected tab and the content area with this approach? I tried this but it got very messy

Noel's profile picture
Noel2 months ago

Distance-to-progress driving the border radii is such a clean trick. Most people overbuild this with SVG morphs — mapping drag distance to radius keeps it buttery and still reads like real material.

Jawad Sarwar's profile picture
Jawad Sarwar2 months ago

So cool!

oluwasefunmi.'s profile picture
oluwasefunmi.2 months ago

This is so cool!

Michael Stevanus Hartono's profile picture
Michael Stevanus Hartono2 months ago

woww soo cool kevin 👏

Related Videos

CSS Trick! 🤙 You can create gradient borders on translucent elements using mask-clip and mask-composite with a pseudo-element 🔥 .gradient-border::after { mask-clip: padding-box, border-box; mask-composite: intersect; mask: linear-gradient(transparent, transparent), linear-gradient(white, white); } It's the same "Transparent border trick" from before. But, now you apply it to a pseudo-element 😎 The trick is to create a pseudo-element with a gradient background and then mask it so we only see the part we want, the border ✨ mask-clip defines the area affected by a mask. Similar to how you can define background-size. Using padding-box and border-box constrains the two masks. mask-composite is the magic part ✨ It defines a compositing operation for stacked mask layers. Using intersect means that the parts that overlap get replaced. And this seems to work in all browsers 🙌 As for the rest of the styles... – Make sure you set pointer-events: none on the pseudo-element – Make sure it fills the parent element. You can use position: absolute and inset: 0 – Make sure the background fills the space including the border-width. You can use calc to achieve that: --bg-size: calc(100% + (2px * var(--border))); background: var(--gradient) center center / var(--bg-size) var(--bg-size); That's it! 🚀 Gradient borders on translucent elements. You can set all the backdrop-filter: blur() you like! 😅 CodePen.IO link below! 👇

jhey ʕ•ᴥ•ʔ

269,966 views • 3 years ago

CSS Tip! ✨ It's 2024 and you have a new way to make animated borders 🚀 .glow::after { offset-path: rect(0 100% 100% 0 round var(--radius)); animation: loop; } @​keyframes loop { to { offset-distance: 100%; }} Using the offset-* properties you can animate elements along the perimeter of others 😍 The rect() value gained support in Safari 17.2 🙌 To start, you create an element and put it inside your main element. For example, you put a span inside the button 🤙 Click me! Make the element fill its parent with absolute positioning and inset [data-glow] { position: absolute; inset: 0; } Now the good part, you use a pseudoelement on that element and define an offset-path [data-glow]::after { content: ""; offset-path: rect(0 auto auto 0 round var(--radius)); animation: loop 2.6s infinite linear; } With the rect value, you are saying the path fills the parent container: top: 0 right: auto || 100% bottom: auto || 100% left: 0 Then you can use round to make sure the path uses the same radius as whatever the parent has The @​keyframes animation merely animates the offset-distance of that pseudoelement to 100% @​keyframes loop { to { offset-distance: 100%; }} You can see this more clearly in the video 🫶 The offset-* properties also include an offset-anchor property. This allows you to dictate which point of the element follows the path. For example: anchor-offset: 100% 50%; This means that the "right, center" of the element will follow the perimeter of the parent element 🤙 Lastly, the visuals 🎨 For color, you can use a gradient such as a linear gradient to fill the pseudo-element. [data-glow]::after { background: radial-gradient( circle at right, hsl(320 90% 100%), transparent 50% ); } Then clip away everything so you only have the border and can still have translucent backgrounds, etc. Use a mask with mask-composite ✨ A little transparent border trick: [data-glow] { border: 2px solid transparent; mask: linear-gradient(transparent, transparent), linear-gradient(white, white); mask-clip: padding-box, border-box; mask-composite: intersect; } Bit of a long one. Hope you find it useful 🙏 CodePen.IO link below 👇

jhey ʕ•ᴥ•ʔ

283,498 views • 2 years ago