Xavier Prudent
Xavier Prudent

Reputation: 1742

Aligning a text vertically in R shiny

After having tried various things I found that straighforward but useful way of moving vertically a piece of text and want to share it so that other users of Stacks may benefit of it (as I myself benefit A LOT of thi site):

If you do

fluidRow(
column(width=1,offset=1, h4("Test")),
column(width=2,offset=1, numericInput("sf1.2", label = "Mesure #1", value = 0))

in a ui.R script with R shiny, you notice that "test" is off by regards to the numeric input. To have "test" nicely centered by regards to the numeric input just use the padding option:

fluidRow(
column(width=1,offset=1, h4("Test", style="padding:20px;")),
column(width=2,offset=1, numericInput("sf1.2", label = "Mesure #1", value = 0))

Upvotes: 4

Views: 9382

Answers (2)

Alex Yahiaoui Martinez
Alex Yahiaoui Martinez

Reputation: 1004

The following lignes of code should be used to automate yours.

fluidRow(
column(width=1,offset=1, h3("Test", style="text-align: center;")),
column(width=2,offset=1, numericInput("sf1.2", label = "Mesure #1", value = 0))

Upvotes: 2

Xavier Prudent
Xavier Prudent

Reputation: 1742

just use the padding option:

fluidRow(
column(width=1,offset=1, h4("Test", style="padding:20px;")),
column(width=2,offset=1, numericInput("sf1.2", label = "Mesure #1", value = 0))

Upvotes: 5

Related Questions