Skip to main content
Nathan_Lindahl
February 24, 2021
Question

How can I center align an icon + text with "fill container"?

  • February 24, 2021
  • 12 replies
  • 8596 views

Hi, new Figma user here,

I have the challenge of creating table cells for my company’s design system. Our tables are primarily for marketing purposes and frequently make use of iconography. Components work great when left aligned.

However, when centered, fill container leaves space between the icon and the text and hug contents won’t wrap:

Any tips?

This topic has been closed for replies.

12 replies

Wolfgang_H
May 13, 2021

Can you take a screenshot that includes the layer panel and design panel so that we can see what’s going on behind the scenes? You could also make a new file, drop the content in there, set sharing to public, and give us the link. It will be easier to deduce your problem that way.

Nathan_Lindahl
May 14, 2021

Thanks for the tip @Wolfgang_H!

I played around with this for a bit and I think that what I want to do isn’t possible in this version of autolayout. But Figma link is here if you want to take a look:

Figma – 13 May 21
Wolfgang_H
May 15, 2021

You just need to switch the text to “fill container” instead of hug contents. 🙂

Copy of file where I switched it:

Figma – 15 May 21

Nathan_Lindahl
May 17, 2021

Thanks for looking into it @Wolfgang_H!
However, that doesn’t accomplish what I’m trying to do. As a component in our system, it needs to hold different amounts of text. “Hug content” keeps the icon next to the text but doesn’t allow wrapping. “Fill container” allows wrapping but left aligns the icon instead of centering it with the text.

For the design system I’m working on, the text needs to wrap AND the icon needs to be center aligned with the text.

Again, I’m doubtful a there’s a solution for this without manually updating the component per instance. It’s not make or break for our needs, just not ideal.

Sarah_Lund1
October 25, 2023

I know this concern is old news for the people involved but there was no conclusion left from anyone about whether or not this is possible. I’m having the same problem and have been trying to work on it and wanted to revive this thread to see if there are any new solutions!

Basically, I am similarly working on a table component for my work and in the header cells I want to have the sort icon hug the text but need the text to be able to wrap and truncate if the column is shorter with long text or additional elements take up space on hover. I’ve been trying to figure out if the new min/max feature can help but it hasn’t in this case, it also is too limiting with varying title lengths and header widths.

Nate_G
Power Member
October 26, 2023

@Sarah_Lund1 You could add a max width to the title section and switch between different variant states: Default, Truncated, or Stacked.

Get example file

Nate G
Sarah_Lund1
October 26, 2023

I’ll try this out and see if it works for our situation, thank you!

Nate_G
Power Member
October 31, 2023

Any luck @Sarah_Lund1 ?

Nate G
Sarah_Lund1
November 1, 2023

It works for the most part but is still tricky since the default state of the header has no icons, sort or right icon actions, while they appear on hover.

Nate_G
Power Member
November 1, 2023

I updated the file and added some rough hover examples, but yes it does get tricky.

Hover Examples
View Update File

Nate G