To show fileinput and actionbutton inline

ぃ、小莉子 提交于 2019-12-11 19:17:37

问题


I am trying to build an app using R shiny where I am using fileinput and action button in same box. I am facing issues to show above two inline. Refer to below working example:

library(shiny)
library(shinydashboard)

ui <- dashboardPage(
  dashboardHeader(title = "Inline Widgets Issue"),
  dashboardSidebar(
  ),
  dashboardBody(  
    box(title = "Working Example",width=40 ,status = "warning", solidHeader = TRUE, collapsible = FALSE,
        fluidRow(column(width=8,fileInput('file1', 'Browse File',width="100%",
                                           accept=c('text/csv', 'text/comma-separated-values,text/plain', '.csv'))),
                        column(width=2,actionButton("save","Save!!")))
    ))
)

server <- function(input, output) {

}

shinyApp(ui, server)

Currently this is the situation:

I want something like this:


回答1:


You could add a style tag to your action button:

library(shiny)
library(shinydashboard)

ui <- dashboardPage(
  dashboardHeader(title = "Inline Widgets Issue"),
  dashboardSidebar(
  ),
  dashboardBody(  
    box(title = "Working Example",width=40 ,status = "warning", solidHeader = TRUE, collapsible = FALSE,
        fluidRow(column(width=8,fileInput('file1', 'Browse File',width="100%",
                                          accept=c('text/csv', 'text/comma-separated-values,text/plain', '.csv'))),
                 column(width=2,actionButton("save","Save!!"))),
        tags$style(type='text/css', "#save { width:100%; margin-top: 25px;}")
    ))
)

server <- function(input, output) {

}

shinyApp(ui, server)

you can also play around with width and margin-top to change the size and position of the action button.



来源:https://stackoverflow.com/questions/50532088/to-show-fileinput-and-actionbutton-inline

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!