2

I am trying to add a box as part of a Shiny application to contain some text (instructions) and an image (logo) at the top of the application. This is the code I have so far.

frow5 <- fluidRow(
  box(
    title = "Instructions"
    ,status = "primary"
    ,solidHeader = FALSE 
    ,collapsible = FALSE 
    ,textOutput("instructions")
    , height = 320
    , width = 12
    , align='ccc'


  )

)

output$instructions <- renderText("Some text")

At the moment I have specified a textOuput parameter, but I need an image to be included as part of the same box, aligned right. any suggestions?

OwlieW
  • 217
  • 6
  • 13

1 Answers1

8

How about adding a fluidRow inside the box, having 2 columns, one for text and the other for the image?

box(title = "Instructions",
    status = "primary",
    solidHeader = F,
    collapsible = F,
    width = 12,
    fluidRow(column(width = 10, textOutput( "instructions" )),
             column(width = 2, align = "center",
                      img(src="http://images.all-free-download.com/images/graphiclarge/natural_beauty_highdefinition_picture_166133.jpg", width=100))))

enter image description here

cmbarbu
  • 4,354
  • 25
  • 45
shosaco
  • 5,915
  • 1
  • 30
  • 48
  • This looks brilliant, thank you very much! However, I am trying to use a JPeg saved in my directory but I cant get it to show. Any ideas? – OwlieW May 31 '17 at 09:01
  • 1
    create a folder called `www` in your app.R-Directory, and reference it using `img(src='yourpic.jpeg')` (without www - shiny will look there automatically) – shosaco May 31 '17 at 09:18
  • Thank you yes, I realised that once I posted the comment =) – OwlieW May 31 '17 at 09:23