Button

Displays a button or a component that looks like a button.

buridan add button

Component Guide

Use the following to build the Button component.

from components.ui.button import button

Source 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.

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.

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")
Prop Type Default
variant Literal["default", "destructive", "outline", "secondary", "ghost", "link"] "default"
size Literal["default", "xs", "sm", "lg", "icon", "icon-xs", "icon-sm", "icon-lg"] "default"
class_name str ""

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"),
)
Arg Type Default
variant Literal["default", "destructive", "outline", "secondary", "ghost", "link"] "default"
size Literal["default", "xs", "sm", "lg", "icon", "icon-xs", "icon-sm", "icon-lg"] "default"