A shadcn-style button. Renders a native <button> (or <a> when href is
supplied). Supplying inputId makes it a Shiny action button (readable as
input$<inputId> click count).
Usage
shad_button(
label = NULL,
inputId = NULL,
variant = c("default", "secondary", "destructive", "outline", "ghost", "link"),
size = c("default", "sm", "lg", "icon"),
icon = NULL,
icon_position = c("left", "right"),
icon_size = c("default", "sm", "lg"),
loading = FALSE,
disabled = FALSE,
href = NULL,
aria_label = NULL,
type = "button",
class = NULL,
...
)Arguments
- label
Button text.
- inputId
Optional input id. When set, the button becomes a Shiny action button.
- variant
One of
"default","secondary","destructive","outline","ghost","link".- size
One of
"default","sm","lg","icon".- icon
Optional leading/trailing icon: a
shad_icon()name or a tag.- icon_position
"left"or"right".- icon_size
For
size = "icon", an additional"default","sm"or"lg"sizing.- loading
If
TRUE, shows a spinner, disables the button, and setsaria-busy.- disabled
If
TRUE, disables the button.- href
Optional URL; renders an
<a class="shad-btn">instead.- aria_label
Accessible label (required for icon-only buttons).
- type
Button
typeattribute (ignored for anchors).- class
Extra CSS classes.
- ...
Extra attributes or child tags.
See also
shad_toast(), update_shad_button()
Other shadshiny tier-1 components:
shad_alert(),
shad_aspect_ratio(),
shad_avatar(),
shad_badge(),
shad_breadcrumb(),
shad_button_group(),
shad_card(),
shad_code_block(),
shad_empty(),
shad_item(),
shad_kbd_group(),
shad_label(),
shad_progress(),
shad_scroll_fade(),
shad_separator(),
shad_shimmer(),
shad_skeleton(),
shad_spinner(),
shad_table(),
shad_typography
Examples
shad_button("Save", variant = "default")
#> <button type="button" class="shad-btn shad-btn--default">Save</button>
shad_button("Delete", variant = "destructive", icon = "x")
#> <button type="button" class="shad-btn shad-btn--destructive">
#> <svg class="shad-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>
#> Delete
#> </button>
shad_button(inputId = "go", "Run")
#> <button type="button" id="go" class="shad-btn shad-btn--default action-button">Run</button>