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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With