blastula icon indicating copy to clipboard operation
blastula copied to clipboard

gt table not centered in email

Open algo-se opened this issue 3 years ago • 2 comments

Is there a way to center a table when sending a email? Using outlook client the table is left-align, however when rendering the email in the browser it looks fine.

reprex:

exibble_a <-
  exibble %>%
  dplyr::select(-c(fctr, date, time, datetime)) %>%
  gt(rowname_col = "row", groupname_col = "group") %>%
  fmt_missing(columns = everything())
  
exibble_a_html <- as_raw_html(exibble_a)

email <-
  compose_email(
    body = md(
      c(
        '## My email',
        "This is my email. The table is not centered:",
        exibble_a_html
      )
    )
  )

email %>%
  smtp_send(
    from = "[email protected] ",
    to = c("[email protected]"),
    subject = "hello",
    credentials = creds_key(id = "powerbigw")
  )

Browser: image

Outlook Client: image

algo-se avatar Feb 04 '21 09:02 algo-se

Hi, I´ve managed to hack this using block_articles:

email <-
  compose_email(
    body =
      blocks(
        block_text(
          md(
            c(
              '## My email',
              "The table now looks centered but is weird in android:"
            ))
        ),
        block_articles(
          article(),
          article(content = exibble_a_html),        # is centered but looks weird in outlook android app
          article()
        ),
        block_text("Outside block_articles looks fine:"),
        exibble_a_html                              # looks ok but not centered
      )
  )


email %>%
  smtp_send(
    from = "me@me",
    to = c("me@me"
    ),
    subject = "Hola",
    credentials = creds_key(id = "id")
  )

Which looks centered in the outlook client: image

BUT now looks weird in the outlook android app 😢 : Clic for long picture

algo-se avatar Feb 04 '21 10:02 algo-se

We will take a closer look at this later in the year (when we start working on blastula again). As a workaround, you can save the gt table as an image with gtsave(), and it's not a bad option unless you need copy/paste ability.

rich-iannone avatar Mar 16 '21 19:03 rich-iannone