Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Shiny titlepanel: how to put title and image at same height?

I want both a title and an image in my titlepanel, but the title on the left and the image on the right. I got them both in the panel using this code:

ui <- fluidPage(
   titlePanel(div("Fenologische modellen", 
                   img(height = 105, width = 300, src = "logo_pcfruit.jpg"))
   ),

enter image description here

But then they're just next to eachother. Because align did not work for the image (or "style = ...", tried that too), I decided to put them both in different columns, which requires a fluidRow first.

ui <- fluidPage(
  titlePanel( 
    fluidRow( 
      column(4, "Fenologische modellen"),
      column(4, offset = 8, img(height = 105, width = 300, src = "logo_pcfruit.jpg"))
    )
  ),

What happens is that the image is indeed placed on the right, but it's been placed bottom right, while I need it to be on the same line as the title.

enter image description here

I've tried adjusting the height of the columns in pixels, but under a certain height, it didn't change anymore. The picture above shows the limit.

Any suggestions?

PS: I do not want to group both of them in a wellpanel, unless I can make it completely white and thus invisible.

like image 734
Tingolfin Avatar asked Oct 28 '16 07:10

Tingolfin


1 Answers

So I figured it out myself while trying to solve the same problem in a wellPanel. The bad guy is the offset argument in column(). If I remove it, the image and title are horizontally aligned.

To put the image on the right, I just have to make the left column very wide:

titlePanel(
  fluidRow(
    column(9, "Fenologische modellen"), 
    column(3, img(height = 105, width = 300, src = "logo_pcfruit.jpg"))
  )
),

enter image description here

like image 191
Tingolfin Avatar answered Oct 21 '22 10:10

Tingolfin