Button
Displays a button or a component that looks like a button.
Installation
Command to install the Button component.
Component Guide
Use the following to build the Button component.
from components.ui.button import buttonSource Code & Dependencies
For manual installation, copy each of the source codes below in their respective locations.
components/core/core.py
components/ui/button.py
Examples
Sizes
Use the size prop to change the button's size.
Props used: size on button.
Default
Props used: none required — variant="default" is the default.
Secondary
Props used: variant on button.
Outline
Props used: variant on button.
Ghost
Props used: variant on button.
Link
Props used: variant on button.
Destructive
Props used: variant on button.
Icon
Props used: size="icon" on button.
With Icon
Add data-icon="inline-start" or data-icon="inline-end" to the icon child for correct spacing.
Props used: data_icon on the icon child.
Rounded
Props used: class_name="rounded-full" on button.
Spinner
Render a spinner() inside the button for a loading state, with the same data-icon positioning convention as icons.
Props used: data_icon on the spinner child.
As Link
Use button_variants(...) to generate the button's classes as a plain Var, applied to a real rx.el.a. Don't wrap an <a> inside button(...) — the underlying Base UI Button always sets role="button", which overrides the link's semantic role.
Props used: variant, size args on button_variants(...).
API Reference
button
button("Click me", variant="outline", size="sm")
Any other prop accepted by the underlying Base UI Button is also passed straight through.
button_variants
Returns the same classes button(...) would apply, as a plain Var[str] — for styling a non-button element (like a link) to look like a button, without wrapping it in an actual <button>.
rx.el.a(
"Go to docs",
href="/docs",
class_name=button_variants("outline", "sm"),
)