Skip to contents

A shadcn toggle group. input$<inputId> is a string/NULL (single mode) or a character vector (multiple mode).

Usage

shad_toggle_group(
  inputId,
  choices,
  selected = NULL,
  type = c("single", "multiple"),
  variant = c("default", "outline"),
  size = c("default", "sm", "lg"),
  orientation = c("horizontal", "vertical"),
  disabled = FALSE,
  class = NULL,
  ...
)

shad_toggle_group_item(value, label = NULL, icon = NULL, disabled = FALSE)

Arguments

inputId

Input id.

choices

A named/unnamed vector or a list of shad_toggle_group_item().

selected

Initially pressed value(s).

type

"single" or "multiple".

variant

"default" or "outline".

size

"default", "sm", or "lg".

orientation

"horizontal" (default) or "vertical".

disabled

If TRUE, disables every item.

class

Extra CSS classes.

...

Extra attributes on the group root.

value

The item's value.

label

The item's label (defaults to the value).

icon

Optional icon for the item.

Value

A toggle-group tag.

Examples

shad_toggle_group("align", choices = c(Left = "left", Center = "center",
                  Right = "right"), selected = "center", type = "single")
#> <div class="shad-toggle-group" data-shad="toggle-group" id="align" data-type="single" role="group">
#>   <button type="button" class="shad-toggle" data-value="left" data-state="off">Left</button>
#>   <button type="button" class="shad-toggle" data-value="center" data-state="on">Center</button>
#>   <button type="button" class="shad-toggle" data-value="right" data-state="off">Right</button>
#> </div>