Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between TextOutput and VerbatimTextOutput in R Shiny

Tags:

r

shiny

I want to display plain text in my Shiny app and I found the TextOutput and VerbatimTextOutput UI elements. From the documentation, I can see that they both escape HTML. According to the same documentation, they are often combined with different render functions, but that doesn't make the UI element different.

Where do they differ?

like image 441
takje Avatar asked Jan 25 '23 12:01

takje


1 Answers

Apparently, the difference is in how they present the plain text.

VerbatimTextOutput uses the HTML pre tag. The pre tag uses a fixed-width font (e.g. Courier) and does not modify line breaks and spaces. Therefore this is excellent to present formatted text such as code.

TextOutput uses the div tag. The div tag does not necessarily use a fixed-width font (unless you use specific CSS). It also does not keep line breaks and multiple spaces in the same way that pre does. This is more suited for prose.

like image 106
takje Avatar answered Feb 06 '23 15:02

takje