Field

Description

Create a form field that groups a control with its label and helper text.

Usage

bc_field(..., orientation = "default", disabled = FALSE, invalid = FALSE)

bc_fieldset(..., legend = NULL, description = NULL)

bc_field_group(..., aria_label = NULL)

bc_field_separator()

Arguments

Argument Description
... Tag attributes and content.
orientation String. One of default, horizontal, responsive.
disabled Bool. Whether to show the field as disabled. Defaults to FALSE.
invalid Bool. Whether to show the invalid state. Defaults to FALSE.
legend String or tag. The fieldset title.
description String or tag. Text under the title.
aria_label String. Accessible name for the group.

Value

An htmltools tag.

Details

Pass the label, control, and helper text in that order. In a horizontal field, pass the control first.

Examples

bc_field(
  htmltools::tags$label(`for` = "username", "Username"),
  htmltools::tags$input(id = "username", type = "text"),
  htmltools::tags$p("Choose a unique username for your account.")
)

Choose a unique username for your account.


bc_field(
  htmltools::tags$input(id = "sync", type = "checkbox", role = "switch"),
  htmltools::tags$label(`for` = "sync", "Sync folders"),
  orientation = "horizontal"
)

bc_fieldset(
  legend = "Address Information",
  description = "We need your address to deliver your order.",
  bc_field(
    htmltools::tags$label(`for` = "street", "Street"),
    htmltools::tags$input(id = "street", type = "text")
  )
)
Address Information

We need your address to deliver your order.


bc_field_group(
  aria_label = "Account credentials",
  bc_field(
    htmltools::tags$label(`for` = "email", "Email"),
    htmltools::tags$input(id = "email", type = "email")
  ),
  bc_field_separator(),
  bc_field(
    htmltools::tags$label(`for` = "password", "Password"),
    htmltools::tags$input(id = "password", type = "password")
  )
)