Note that because this demonstration uses rmarkdown::html_document(), we can use Bootstrap classes to customize the chunk outputs.

# setup
knitr::opts_chunk$set(
  class.output  = "bg-success",
  class.message = "bg-info text-info",
  class.warning = "bg-warning text-warning",
  class.error   = "bg-danger text-danger"
)

Normal

paste("Normal", "R chunk", "output!!")
## [1] "Normal R chunk output!!"

Message

message("This is a message")
## This is a message

Warning

warning("This is a warning")
## Warning: This is a warning

Error

stop("An error occurred in this chunk.", call. = FALSE)
## Error: An error occurred in this chunk.