An LCARS styled toggle button that can be used in place of shiny::checkboxInput() and lcarsCheckbox().

lcarsToggle(
  inputId,
  label,
  value = FALSE,
  pill = FALSE,
  inverse = FALSE,
  true = "Yes",
  false = "No",
  true_color = "dodger-pale",
  false_color = "atomic-tangerine",
  background_color = "#000000",
  border_color = ifelse(inverse, false_color, background_color),
  outer_border = FALSE,
  outer_color = "#000000",
  label_color = "#FFFFFF",
  label_right = FALSE,
  width = NULL
)

Arguments

inputId

character, the input slot that will be used to access the value.

label

character, display label for the control, or NULL for no label.

value

logical, initial value.

pill

logical, use an LCARS pill style with rounded ends instead of the default rounded rectangle.

inverse

logical, invert the color presentation.

true

character, text label for TRUE position.

false

character, text label for FALSE position.

true_color

Color for TRUE position. Can be any color given in hex format. Named colors must be LCARS colors. See lcarsdata for options.

false_color

Color for FALSE position, as above.

background_color

background color, as above.

border_color

border color, as above.

outer_border

logical, use outer border. This makes some adjustments to inner elements if used.

outer_color

outer border color, as above.

label_color

label text color, as above.

label_right

logical, set to TRUE to right align label text.

width

character, use only px units for this widget, e.g. "150px" (the default when NULL). Percentage is the only other unit allowed. It works, but not as well. Fixed widths recommended.

Value

A toggle button control that can be added to a UI definition.

Examples

## Only run examples in interactive R sessions
if(interactive()){
  ui <- lcarsPage(
    lcarsToggle("somevalue", "Some value", FALSE),
    verbatimTextOutput("value")
  )
  server <- function(input, output) {
    output$value <- renderText({ input$somevalue })
  }
  shinyApp(ui, server)
}