1

I trying to reduce the top margin of checkboxinput because is diferente than anothers inputs, as you can see in the first menutitem, even when I define a top margin equal to 0px. The solution that I found was define a negative top margin, but when I define it and the checkbox is hiden the actionLink top margin reduce.

Can anyone solve this problem???

library(shiny)
library(shinydashboard)


ui <- dashboardPage(
  dashboardHeader(),
  dashboardSidebar(
    menuItem("teste",
             textInput("text","Text"),
             uiOutput("check_box_out",style="margin-left: 16px;margin-    top:0px;margin-bottom:16px"),
            actionLink("button", "Show checkbox",style="margin-left: 16px;margin-top:16px;margin-bottom:16px")),
menuItem("teste2",
         textInput("text2","Text2"),
         uiOutput("check_box_out2",style="margin-left: 16px;margin-top:-20px;margin-bottom:16px"),
         actionLink("button22", "Show checkbox2",style="margin-left: 16px;margin-top:16px;margin-bottom:16px"))
 ),
 dashboardBody())

server <- function(input, output, session) {
 observe({   
   observeEvent(input$button,{
  output$check_box_out <- renderUI({

    checkboxInput("check_box","checkboxinput",value = F)

  })
 })

 observeEvent(input$button22,{
   output$check_box_out2 <- renderUI({

     checkboxInput("check_box2","checkboxinput2",value = F)

   })
  })
 })
}

shinyApp(ui= ui, server = server)
  • Try `tags$head(tags$style(type = "text/css", ".shiny-input-container {padding-top: 0px !important;}"))` and see if this works for you. This removes the top padding for all input elements. Selecting `checkboxInput` specificly is not that easy. – K. Rohde May 13 '16 at 14:51
  • thank you for your answer, it's works, but i have a dateRangeInput and it's loose it margin! – Pedro Oliveira May 13 '16 at 15:51
  • To be clear, your enemy is the padding-top from class shiny-input-container. Sadly, this includes all Kind of input elements. If you would find a clever CSS Selector to only get the elements, you'd be set. – K. Rohde May 13 '16 at 19:00
  • See this answer from me for another question http://stackoverflow.com/questions/36898492/aligning-checkbox-elements-in-many-coumns-in-a-shiny-app/36899078#36899078 The key is to get only the checkbox div – Xiongbing Jin May 13 '16 at 21:36
  • thanks, the checkbox div works, but i had to put a negative margin! – Pedro Oliveira May 16 '16 at 08:43

0 Answers0