I'm using renderText
to display some dynamic output in my Shiny web app. Now how can I include a bullet points in the dynamic output?
shiny::tags is a list of 110 functions. Each function builds a specific HTML tag. If you are familiar with HTML, you will recognize these tags by their names. You can build UI by using HTML tags.
You can use tahs$h1() to h6() to add headings, or add text using textOutput(). You can add text using text within quotes(" ").
An expression that returns an R object that can be used as an argument to cat . env. The environment in which to evaluate expr .
Use renderText in server to tell Shiny how to build the text. You'll need to use the same name to refer to the text in both scripts (e.g., "min_max" ). Your text should use both the slider's min value (saved as input$range[1] ) and its max value (saved as input$range[2] ).
Assuming you are using UI.R
and not a custom HTML UI, you should be able to use either the HTML
function or the tags
function for this.
Please be advised I am writing this out of my head, so the code is untested.
HTML("<ul><li>...text...</li><li>...more text...</li></ul>")
Or
tags$div(
tags$ul(
tags$li("text")
)
)
Update: I first missed the dynamic word in your question, which is why I only mentioned UI.R
(thanks to @StephaneLaurent for pointing it out).
In order to make your bulleted list dynamic you should use renderUI
in your server.R
. This function expects the expression it wraps to be HTML. Then, you can specify in your UI.R
where to put the list by using uiOutput
.
The code would look more or less like this:
UI.R
#other elements before the list
uiOutput("myList")
#other elements after the list
server.R
output$myList <- renderUI(HTML("<ul><li>...text...</li><li>...more text...</li></ul>"))
You can find more information on renderUI
in the docs, and a brief explanation about using it for dynamic UIs in the tutorial.
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