gt icon indicating copy to clipboard operation
gt copied to clipboard

location `cells_all()`

Open vincentarelbundock opened this issue 6 years ago • 4 comments

It would be useful to have a shortcut to apply some styling to all locations:

tab %>% tab_style(style = cells_styles(text_size = 'x-small'),
                  locations = cells_all())

vincentarelbundock avatar Feb 13 '19 03:02 vincentarelbundock

Thanks for the suggestion! It's a very good idea, especially for that use case of globally modifying the text size.

rich-iannone avatar Feb 21 '19 13:02 rich-iannone

This would be a handy way to set the same font for the entire table too, unless I'm missing another way of accomplishing this.

gregrs-uk avatar Mar 05 '19 17:03 gregrs-uk

I think this would be a great feature. Especially for when changing something like the font of an entire table.

However, I think text size might need an additional option on top of this. The reason is that often you won't want to change all the text in a table to the same font size, you will often want to either enlarge or reduce the text size of the different components by a fixed increment. That means that although your footnotes, for example, will be slightly larger, they will still be smaller than the other text in the table. Likewise for the headers and sub-headers etc. still being larger.

It would be useful to be able to specify an anchor_text_size perhaps in the gt() function at the outset? Therein one could specify the size for the text in the normal cells (eg "small") and the text in the other components of the table would adjust to that anchor (eg. "x-small" for the foornotes, "medium" for the sub-heading, "large" for the heading etc).

Another option to achieve this might be to have a helper function like reduce_text_size() which could be specified as a function passed to the fn= argument in text_transform(). It could then be used like so:

a_gt_table %>%
  text_transform(locations = cells_all(),
                 fn = reduce_text_size(by = px(5))

I'm not sure about this though. You maybe want to keep the values of the text and their styles separate.

jameslairdsmith avatar Jun 30 '19 12:06 jameslairdsmith

@rich-iannone should the difficulty and effort tags for this one be lower? It seems like just addressing the request in the title (for global font changes) would be quite easy?

kendonB avatar May 11 '20 01:05 kendonB