One kind of bootstrap3 input group: a textinput and a button attached to the end

textButton(
  textId,
  btnId = paste0(textId, "_btn"),
  label = "",
  text_value = "",
  placeholder = "",
  tooltip = "",
  placement = "bottom",
  btn_icon = NULL,
  btn_label = "btn",
  style = "",
  ...
)

Arguments

textId

the text input ID

btnId

the button ID, if not specified, it is "textId" + "_btn" like, textId_btn

label

label of the whole group, on the top

text_value

initial value of the text input

placeholder

placeholder text of the text input

tooltip

a tooltip of the group

placement

where should the tooltip go?

btn_icon

a shiny::icon of the button

btn_label

text on the button

style

additional CSS style of the group

...

additional args pass to the button, see shiny::actionButton

Value

a shiny input group

Examples

if(interactive()){
  library(shiny)

  ui <- fluidPage(
    column(
      6,
      textButton(textId = "tbtn_default", label = "default"),
      textButton(
        textId = "tbtn-icon",
        label = "change icon and color",
        btn_icon = icon("house"),
        class = "btn-warning" # pass to the button
      ),
      textButton(
        textId = "tbtn_style",
        label = "change styles",
        style = "color: red; border: 2px dashed green;"
      ),
      textButton(
        textId = "tbtn_submit",
        label = "interact with shiny server",
        btn_label = "Submit",
        placeholder = "type and submit",
        class = "btn-primary"),
      verbatimTextOutput("tbtn_submit_out")
    )
  )

  server <- function(input, output, session) {
    # watch for the button ID "tbtn_submit" + "_btn"
    observeEvent(input$tbtn_submit_btn, {
      output$tbtn_submit_out <- renderPrint(isolate(input$tbtn_submit))
    })

  }

  shinyApp(ui, server)
}