I am trying to add 'Read more' or 'Read less' functionality for long text in my Shiny app. My knowledge related to JS/ html is limited, so if there is any assist regarding communicating information between shiny, js or html that would be helpful.
source: codepen.io/maxds/pen/WNrvZY
CodePudding user response:
If you want to avoid JS you could use the details and summary tags in HTML.
Shiny example
Here is a small example implemented using only Shiny-code:
library(shiny)
ui <- fluidPage(
tags$p("Some information"),
tags$details(
tags$summary("Read more"),
"More information"
)
)
server <- function(input, output) {}
shinyApp(ui = ui, server = server)
HTML example
If you want to use HTML directly you could use add this to your server inside the HTML() function in Shiny:
<p>Some information</p>
<details>
<summary>Read more</summary>
More information
</details>

