I’ve been trying to create a table in Sketch using smart layout. My goal is to have a symbol for a column (to build tables with) that automatically resizes based on content, while having a number of different symbols that can be used for the cells.
So far I’ve been unsuccessfull in making the column resize as a whole. It only resizes the cell. My best attempt was to:
1 create a symbol for the table cell: a rectangle with a text field set on ‘auto width’
2 create a symbol for the table column with the cell symbols
3 add auto layout (horizontal left to right) to both the cell symbol and the column symbol
4 I checked ‘Adjust content on resize’ for the column as well (not sure if that matters at all)
5 none of the elements are pinned in any way
What I end up with is a column that only resizes the cell when adding larger content, not the rest of the column. It seems like it ‘prioritizes’ the layout of the cell (which is related to the text content of that cell) and doesnt care about the layout of the column.
Thanks for sharing this use case! We’ll look into it and post an update here.
This is a fine timing! We’ve just rolled out this post about the latest improvements in Smart Layout, so if you have any other use cases, please feel free to post them there
@Rickvanthof here’s a proposal! I’ll break down the components and also share a sample file. Let me know what you think and also of any tweaks you need!
The key for columns to resize is to separate the text from the background, in that way, overriding one cell makes the entire column grow. So here’s the breakdown of the structure:
I created the column symbol by placing one pair of the base symbols for each cell. In the exercise I did, I created a 10 row column (header included) which has 10 symbols for text, 10 for background
I used the column symbol to create the full table. In this case I put 4 columns, but you can add more and hide unnecessary columns in the instances. Here’s how a new fresh instance looks and also after adding overrides:
Being made of symbols, this setup creates a lot of override fields on the inspector, so I recommend overriding directly on canvas, or using the same structure but with Smart Layout groups.
So what do you think? Let me know and we’ll keep tweaking this and find a solution to your use case!
Thanks for the suggestion. Technically this works, but I prefer being able to build tables using column symbols. In my designs I almost always use either 5-10-15 rows (since those are the most common pagination options) but the number of columns can vary between 2 and ±16.