Charles Stangor
Charles Stangor

Reputation: 304

Why don't columns spread across page in Shiny?

I thought the full row was 12, so 4 3-wide columns should fill across the whole page, but this doesn't. library(shiny)

fluidPage(

    mainPanel(

      fluidRow(
        column(3,
               textInput("user_id", "User ID", width = NULL)
        ),

        column(3,
               textInput("name", "Organization name",value = "",width = NULL)
        ),
        column(3,

               textInput("address", "Address",value = "",width = NULL)
        ),
      column (3,
              textInput("zip", "Zip Code",value = "",width = NULL)
      )

      ) #row

    ) #panel

  ) #page

Upvotes: 1

Views: 306

Answers (1)

symbolrush
symbolrush

Reputation: 7457

Per default mainPanel has a width of 8. This can be seen when looking at the docs:

?shiny::mainPanel

mainPanel(..., width = 8)

Therefore you have to explicitly state width = 12 inside your mainPanel call.


fluidPage(

    mainPanel(

      fluidRow(
        column(3,
               textInput("user_id", "User ID", width = NULL)
        ),

        column(3,
               textInput("name", "Organization name",value = "",width = NULL)
        ),
        column(3,

               textInput("address", "Address",value = "",width = NULL)
        ),
      column (3,
              textInput("zip", "Zip Code",value = "",width = NULL)
      )

      ) #row

    , width = 12) #panel

  ) #page

..should do the trick.

Upvotes: 1

Related Questions