Hi, I’m trying to create a circle-to-pill button animation (circle in normal state, then expanding in width to a pill shape), with a text in it, but trying to do it with interactions doesn’t work because the circle just turns into an ellipse when the width changes in hover state. Even if I use a square with corner radius the same thing happens which is weird.
I can do it in css easily, but as we already know Editor X’s god ate its css homework, which is also a bit weird…
Hey, @toto-schillaci . I am Shani, UX Designer at Editor X. Great example and thanks for your feedback, I will share it with our team Unfortunately at this time, we do not support changing the layout of an element (height, width etc.) using interactions panel, but rather only transformations like scale and rotate. In your CSS example, the button width changes on hover, and Scale cannot achieve this.
Hey @toto-schillaci ,
there’s no API for changing the size of elements, but there’s a way to do it if built correctly.
Interactions Tool (No Code)
With the interactions tool, set the font size to small in the Initial state and on hover make it larger
Also there’s a way to build it with Velo
Here’s an illustration, above the button, of how I assigned the grid areas for our button to be flexible.
In the middle area I’ve added a container with 100% width, and a text inside(Collapsed on load) that will determine the width when expanded.
And I used the following Velo code
Click to expand, hover out to collapse
Thank you for the answer, and for taking the time to put these examples together.
I followed your video, and used of the buttons there to create something similar to what I needed - it’s number 9 in your Chamber Buttons 1video that Shani sent me. The problem with that solution is that I couldn’t adapt it to the different screen sizes of a responsive site.
As for the examples above - I am trying to replicate what you’ve done with the interactions tool, but I think I’m missing something… I can get the text to scale from small to large, but not the actual box (pill shape). I’m not completely on board about how the hierarchy is constructed.
@toto-schillaci in order for the container to stretch with your content follow these steps:
Set the left grid column to Min/Max, with min being 50px and max max-content, and right column to 1fr
Now place your green container on the left column, dock it to the left set its width to 100%
Place your text element inside, dock it to the left as well, set its width to 100%, and shrink the font size using interactions in the Initial mode (like your already did)
You can also play with the opacity or coloring of the text for the animation to look nice
Now you should have an all-fluid container that will stretch according to the text
I’m still struggling with the responsive part of it. I’d like the circle (and the text inside of it) to change its size according to the breakpoint. Approx. like this:
desktop: 40px
tablet: 30px
mobile: 25px
When I change the size of the container, the left cell of the grid wouldn’t scale down to 30, 25, etc., resulting in a pill shape at the initial state for tablet and mobile.
@toto-schillaci this can be fixed by adjusting the Min size of the left column of the grid to match the parent container’s height.
So if your container is 30px of height, the left column should be min: 30px, max: max-content