Switch
Description
A binary toggle built on a native checkbox with role="switch", paired with its label in a horizontal field.
Usage
bc_switch(
id,
label,
...,
size = "default",
checked = FALSE,
disabled = FALSE,
invalid = FALSE,
description = NULL,
name = id
)
Arguments
| Argument | Description |
|---|---|
id |
String. The input id, and the for of its label. |
label |
String or tag. The label content. |
... |
Tag attributes for the <input>. |
size |
String. One of default or sm. sm writes data-size="sm". |
checked |
Bool. Whether the box starts ticked. |
disabled |
Bool. Whether the box is disabled. |
invalid |
Bool. Whether to show the invalid state. |
description |
String or tag. Helper text shown under the label, wired to the input with aria-describedby. |
name |
String. The input name, defaulting to id. |
Value
A <div> tag.
Examples
bc_switch("airplane-mode", "Airplane Mode")
bc_switch(
"focus-mode",
"Share across devices",
checked = TRUE,
description = "Focus is shared across devices."
)
Focus is shared across devices.