Skip to content

Commit

Permalink
Merge pull request rstudio#481 from saurfang/master
Browse files Browse the repository at this point in the history
Add inline option for RadioButton and checkboxGroupInput
  • Loading branch information
yihui committed Jun 2, 2014
2 parents 53a401f + 063b58e commit bd0eae0
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions R/bootstrap.R
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,7 @@ checkboxInput <- function(inputId, label, value = FALSE) {
#' @param choices List of values to show checkboxes for. If elements of the list
#' are named then that name rather than the value is displayed to the user.
#' @param selected The values that should be initially selected, if any.
#' @param inline If \code{TRUE}, render the choices inline (i.e. horizontally)
#' @return A list of HTML elements that can be added to a UI definition.
#'
#' @family input elements
Expand All @@ -569,7 +570,7 @@ checkboxInput <- function(inputId, label, value = FALSE) {
#' "Gears" = "gear"))
#'
#' @export
checkboxGroupInput <- function(inputId, label, choices, selected = NULL) {
checkboxGroupInput <- function(inputId, label, choices, selected = NULL, inline = FALSE) {
# resolve names
choices <- choicesWithNames(choices)
if (!is.null(selected))
Expand All @@ -589,7 +590,8 @@ checkboxGroupInput <- function(inputId, label, choices, selected = NULL) {
if (value %in% selected)
inputTag$attribs$checked <- "checked"

tags$label(class = "checkbox",
tags$label(class =
if(inline) "checkbox inline" else "checkbox",
inputTag,
tags$span(name))
}
Expand Down Expand Up @@ -790,6 +792,7 @@ selectizeIt <- function(inputId, select, options, width = NULL, nonempty = FALSE
#' named then that name rather than the value is displayed to the user)
#' @param selected The initially selected value (if not specified then
#' defaults to the first value)
#' @param inline If \code{TRUE}, render the choices inline (i.e. horizontally)
#' @return A set of radio buttons that can be added to a UI definition.
#'
#' @family input elements
Expand All @@ -802,7 +805,7 @@ selectizeIt <- function(inputId, select, options, width = NULL, nonempty = FALSE
#' "Log-normal" = "lnorm",
#' "Exponential" = "exp"))
#' @export
radioButtons <- function(inputId, label, choices, selected = NULL) {
radioButtons <- function(inputId, label, choices, selected = NULL, inline = FALSE) {
# resolve names
choices <- choicesWithNames(choices)

Expand All @@ -826,7 +829,8 @@ radioButtons <- function(inputId, label, choices, selected = NULL) {
inputTag$attribs$checked = "checked"

# Put the label text in a span
tags$label(class = "radio",
tags$label(class =
if(inline) "radio inline" else "radio",
inputTag,
tags$span(name)
)
Expand Down

0 comments on commit bd0eae0

Please sign in to comment.