Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Shiny splitLayout not wrapping HTML text

Tags:

r

shiny

I'm using splitLayout in a Shiny R app to create a two-panel structure that has a plot on the left (a googleVis gVisGeoChart object) and HTML on the right.

This is a mockup of the problematic code:

splitLayout(

    htmlOutput("mychart"), #This winds up rendering properly to the left side of the window

    div(
        h1("A descriptive heading"),
        p("Here's some text that takes more than one line on the screen. I want it to wrap, but it just keeps going to the right out of view in its container.")      
    ) #This text will not wrap to the right side of the splitLayout frame
)

The text inside the p() command will not wrap to the visible (1/2) of the page created by splitLayout. Instead, it keeps going to the (invisible) right, requiring the user to scroll to see it all. This is not the desired behavior (quite frankly, I have a hard time imagining a situation where it is).

How to ensure that the text wraps properly to the splitLayout area?

like image 548
MJG Avatar asked Dec 12 '16 23:12

MJG


1 Answers

Super old, but I've been stuck on this issue for a while and the previous answer did not work. Finally figured it out thanks to some html inspection. You need to add a style element to splitLayout, namely: 'white-space: normal', (it is set to 'white-space: nowrap' by default for splitLayout). See below for it used in context with the original question.

splitLayout(

htmlOutput("mychart"), #This winds up rendering properly to the left side of the window

div(
    h1("A descriptive heading"),
    p("Here's some text that takes more than one line on the screen. I want it to wrap, but it just keeps going to the right out of view in its container.")      
),
cellArgs = list(style='white-space: normal;')
)
like image 63
Peter Mueller Avatar answered Oct 21 '22 21:10

Peter Mueller