# NOT RUN {
### Centering an element
# In most modern browsers you want to horizontally center a tag element using
# the flex layout. Alternatively, you can horizontally center an element
# using `margin(.., right = "auto", left = "auto")`.
div(
  "Nam a sapien. Integer placerat tristique nisl.",
  style = "height: 100px; width: 200px;"
) %>%
  margin(top = 2, r = "auto", b = 2, l = "auto") %>%  # <-
  padding(3) %>%
  background("indigo")
### Building an inline form
# Inline form elements automatically use the flex layout providing you a
# means of creating condensed sets of inputs. However, you may need to adjust
# the spacing of the form's child elements.
# Here is an inline form without any additional spacing applied.
formInput(
  id = "login",
  inline = TRUE,
  textInput(
    id = "name",
    placeholder = "full name"
  ),
  groupInput(
    id = "username",
    left = "@",
    placeholder = "username"
  ),
  checkboxInput(
    id = "remember",
    choice = "Remember me"
  ),
  submit = buttonInput("go", "Login")
)
# Without any adjustments the layout is not great. But, with some styling we
# can make this form sparkle. Notice we are also adjusting the default submit
# button added to the form input.
formInput(
  id = "login2",
  inline = TRUE,
  textInput(
    id = "name",
    placeholder = "full name"
  ) %>%
    margin(r = c(sm = 2), b = 2),  # <-
  groupInput(
    id = "username",
    left = "@",
    placeholder = "username"
  ) %>%
    margin(r = c(sm = 2), b = 2),  # <-
  checkboxInput(
    id = "remember",
    choice = "Remember me"
  ) %>%
    margin(r = c(sm = 2), b = 2),  # <-
  submit = buttonInput(NULL, "Log in") %>%
    margin(b = 2)  # <-
)
# }
Run the code above in your browser using DataLab