Antonio
Antonio

Reputation: 1111

Reduce space between fileInput and text in Shiny

Could you help me to reduce the space between fileInput and text in Shiny? I would like to leave something similar to the Figure that I have attached. The executable code is below.

Thank you!

runApp(
  list(ui = fluidPage(
    fileInput("data", h3("Excel database import")), uiOutput("tab"),
  ),
  server = function(input, output, session){
    url <- a("Google Homepage", href="https://www.google.com/")
    output$tab <- renderUI({
      tagList("Access the page:", url)
    })
  })
)

How is it when executing shiny:

enter image description here

How I would like it to be:

enter image description here

Upvotes: 5

Views: 1369

Answers (2)

St&#233;phane Laurent
St&#233;phane Laurent

Reputation: 84709

Alternatively to Pork Chop's solution, you can insert a div element with a negative margin-top between the two elements you want to be closer:

ui = fluidPage(
  fileInput("data", h3("Excel database import")), 
  div(style = "margin-top: -30px"),
  uiOutput("tab")
)

Upvotes: 10

Pork Chop
Pork Chop

Reputation: 29417

You can apply some style to it and adjust it using margin-top:

library(shiny)
runApp(
    list(ui = fluidPage(
        tags$head(tags$style(' #tab {margin-top:-30px;}')),
        fileInput("data", h3("Excel database import")), uiOutput("tab"),
    ),
    server = function(input, output, session){
        url <- a("Google Homepage", href="https://www.google.com/")
        output$tab <- renderUI({
            tagList("Access the page:", url)
        })
    })
)

Upvotes: 3

Related Questions