Q:

kableExtra with Formattable formatting questions

The code below creates a small table.
It is unclear to me how to make these changes:
1) Less white space between the two bars. Using Inspect Element I can change the padding from 8px to 3px in .table>tfoot>tr>td. Is that the right approach? If so, how do I add the appropriate css to my R Script?
2) Remove the rounding of the color bars. Again, inspect element shows that if I change border_radius:0px and padding-right:0px for each cell the change occurs. But again, this doesn't seem correct.
3) How do I change the color of the font of the text in the cells that have the bars?

library(formattable)
library(kableExtra)
library(knitr)

fraction <- function(x, df) {
  x/df$count
}

df <- tibble (
  Type = c("A", "B", "C"),
  count = c(500, 350, 860),
  Decreasing = c(226, 103, 507),
  Increasing = c(300, 250, 350)
) 

mutate(df,
       Decreasing = color_bar(color = "lightgrey", fun = "fraction", df)(Decreasing),
       Increasing = color_bar(color = "lightgreen", fun = "fraction", df)(Increasing)
) %>% 
  select(Type, Decreasing, Increasing) %>% 

  kable("html", escape = "F", align = c("l", "r", "l")) %>% 
  kable_styling(bootstrap_options = c("striped", "hover", "responsive"), full_width = F, position = "float_left")

A:

color_bar is from the formattable package but the good news is that you can define your own color_bar function (just type color_bar in your R console will give you the source code of color_bar and then you can modify it). It will solve your question 2 & 3. 
color_bar2 <- function (color = "lightgray", fun = "proportion", ...) 
{
  fun <- match.fun(fun)
  formatter(
    "span", 
    style = function(x) style(
      display = "inline-block", 
      direction = "rtl", `border-radius` = "0px", `padding-right` = "2px", 
      `background-color` = csscolor(color), color = csscolor("red"),
      width = percent(fun(as.numeric(x), ...))))
}

mutate(df,
       Decreasing = color_bar2(color = "lightgrey", fun = "fraction", df)(Decreasing),
       Increasing = color_bar2(color = "lightgreen", fun = "fraction", df)(Increasing)
) %>% 
  select(Type, Decreasing, Increasing) %>% 

  kable("html", escape = "F", align = c("l", "r", "l")) %>% 
  kable_styling(bootstrap_options = c("striped", "hover", "responsive"), full_width = F, position = "float_left")

For question 1, if you are rendering your table in rmarkdown, check out this page https://rmarkdown.rstudio.com/html_document_format.html#custom_css for how to use custom_css in rmarkdown. 

