I'm trying to add an editable textbox to my shiny app, the text box I need should be editable and deletable
library(shiny)
ui <- shinyUI(fluidPage(
sidebarPanel(
actionButton("add_btn", "Add Textbox"),
actionButton("rm_btn", "Remove Textbox")
),
mainPanel(uiOutput("textbox_ui"))
))
server <- shinyServer(function(input, output, session) {
Track the number of input boxes to render
counter <- reactiveValues(n = 0)
observeEvent(input$add_btn, {counter$n <- counter$n + 1})
observeEvent(input$rm_btn, {
if (counter$n > 0) counter$n <- counter$n - 1
})
textboxes <- reactive({
n <- counter$n
if (n > 0) {
lapply(seq_len(n), function(i) {
textInput(inputId = paste0("textin", i),
label = paste0("Textbox", i), value = "Hello World!")
})
}
})
output$textbox_ui <- renderUI({ textboxes() })
})
shinyApp(ui, server)
I came across the above code but I need to have a flexible box as in the below code
library(shiny)
ui <- fluidPage(
withTags(
div(
textarea(id = "response2",
class = "form-control shiny-bound-input",
style = "width: 300px; height: 34px")
)
)
)
server<-function(input, output, session) {
output$out <- renderText({
input$response2
})
}
shinyApp(ui = ui, server = server)
Also would it be possible to lock in the text with a save button and an edit button to change it later on ?