cell_fill: Helper for defining custom fills for table cells

View source: R/helpers.R

cell_fillR Documentation

Helper for defining custom fills for table cells


The cell_fill() helper function is to be used with the tab_style() function, which itself allows for the setting of custom styles to one or more cells. Specifically, the call to cell_fill() should be bound to the styles argument of tab_style().


cell_fill(color = "#D3D3D3", alpha = NULL)



The fill color. If nothing is provided, then "#D3D3D3" (light gray) will be used as a default.


An optional alpha transparency value for the color as single value in the range of 0 (fully transparent) to 1 (fully opaque). If not provided the fill color will either be fully opaque or use alpha information from the color value if it is supplied in the #RRGGBBAA format.


A list object of class cell_styles.


Use exibble to create a gt table. Add styles with tab_style() and the cell_fill() helper function.

exibble %>%
  dplyr::select(num, currency) %>%
  gt() %>%
    columns = c(num, currency),
    decimals = 1
  ) %>%
    style = cell_fill(color = "lightblue"),
    locations = cells_body(
      columns = num,
      rows = num >= 5000
  ) %>%
    style = cell_fill(color = "gray85"),
    locations = cells_body(
      columns = currency,
      rows = currency < 100

Function ID


See Also

Other Helper Functions: adjust_luminance(), cell_borders(), cell_text(), cells_body(), cells_column_labels(), cells_column_spanners(), cells_footnotes(), cells_grand_summary(), cells_row_groups(), cells_source_notes(), cells_stub_grand_summary(), cells_stub_summary(), cells_stubhead(), cells_stub(), cells_summary(), cells_title(), currency(), default_fonts(), escape_latex(), google_font(), gt_latex_dependencies(), html(), md(), pct(), px(), random_id()

gt documentation built on May 24, 2022, 5:06 p.m.