Skip to main content
Solved

How to do component based hover with overlaying borders?

  • March 26, 2024
  • 1 reply
  • 294 views

Peter_Uithoven

I want to create a prototype with a button bar, where ideally each item is based on a component with a regular and a hover state. But I’m struggling with how to do the border. Since the hovered instance is often lower in the stacking order of the auto layout, some of it’s borders are under other instances.

When the last or first item doesn’t need a hover state this is probably easier.

In CSS I would probably just increase the z-index on hover. I know there are plenty of feature requests for z-index in Figma.

But maybe there is another trick in Figma for this?

Best answer by Peter_Uithoven

I think I found a reasonable workaround

  1. Create Button component (without left border) (centered border)
  2. Add hover variant (with left border)
  3. Add the interaction so it switches from default to hover on hover.
  4. Create the “button bar” auto layout frame with:
    1. Add a couple of Button instances
    2. Give it a 0 gap
    3. Give it a left (also centered) border (to compensate for the missing border

Note that the button can’t have a fill, otherwise it will hide the button bar’s left border.

Simple example:

Figma – 26 Mar 24
View original
This topic has been closed for comments

1 reply

Peter_Uithoven

I think I found a reasonable workaround

  1. Create Button component (without left border) (centered border)
  2. Add hover variant (with left border)
  3. Add the interaction so it switches from default to hover on hover.
  4. Create the “button bar” auto layout frame with:
    1. Add a couple of Button instances
    2. Give it a 0 gap
    3. Give it a left (also centered) border (to compensate for the missing border

Note that the button can’t have a fill, otherwise it will hide the button bar’s left border.

Simple example:

Figma – 26 Mar 24

Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings