Learn R Programming

yonder (version 0.1.0)

formGroup: Add labels, help text, and formatting to inputs

Description

Form groups are a way of labelling an input. Form rows are similar to columns()s, but include additional styles intended for forms. The flexibility provided by form rows and groups means you can confidently develop shiny applications for devices and screens of varying sizes.

Usage

formGroup(label, input, ..., help = NULL, width = NULL)

formRow(...)

Arguments

label

A character string specifying a label for the input or NULL in which case a label is not added.

input

A tag element specifying the input to label.

...

For formGroup, additional named arguments passed as HTML attributes to the parent element.

For formRow, any number of formGroups or additional named arguments passed as HTML attributes to the parent element.

help

A character string specifying help text for the input, defaults to NULL, in which case help text is not added.

width

A responsive argument. One of 1:12 or "auto" specifying a column width for the form group, defaults to NULL.

See Also

Other layout: column, fieldset, flex, navbar

Examples

Run this code
# NOT RUN {
## Grid layout forms

# Use responsive arguments to adjust form layouts based on viewport size.
# Be sure to adjust the size of your browser window between large and small.

card(
  formRow(
    formGroup(
      width = c(md = 6),  # <-
      label = "Email",
      emailInput(
        id = "email",
        placeholder = "e@mail.com"
      )
    ),
    formGroup(
      width = c(md = 6),  # <-
      label = "Password",
      passwordInput(
        id = "password",
        placeholder = "123456"
      ),
      help = "Please consider something better than 123456"
    )
  ),
  formGroup(
    label = "Username",
    groupInput(
      id = "username",
      left = "@"
    )
  ),
  buttonInput(
    id = "go",
    label = "Go!"
  ) %>%
    background("blue")
) %>%
  margin(3) %>%
  background("grey")

# }

Run the code above in your browser using DataLab