✨ Announcing our seed funding led by Lux Capital! Read more about it on our blog
DocsBlogChangelog

Search documentation...

/

Star

12k+

[ Learn ]

[ Concepts ]

[ Reference ]

Button


A button is a clickable element that is used to trigger an event.
rx.button("Click Me!")
Buttons can range in size and style. You can style it with traditional props or with the color scheme prop for ease of use.
rx.button_group(
    rx.button(
        "Example", bg="lightblue", color="black", size="sm"
    ),
    rx.button(
        "Example", bg="orange", color="white", size="md"
    ),
    rx.button("Example", color_scheme="red", size="lg"),
    space="1em",
)
Buttons can also have different visual states.
rx.button_group(
    rx.button(
        "Example",
        bg="lightgreen",
        color="black",
        is_loading=True,
    ),
    rx.button(
        "Example",
        bg="lightgreen",
        color="black",
        is_disabled=True,
    ),
    rx.button(
        "Example",
        bg="lightgreen",
        color="black",
        is_active=True,
    ),
    space="1em",
)
You can group buttons together using button group.
rx.button_group(
    rx.button(rx.icon(tag="minus"), color_scheme="red"),
    rx.button(rx.icon(tag="add"), color_scheme="green"),
    is_attached=True,
)
Buttons are use to trigger events using theon_click event handler.

0

class ButtonState(rx.State):
    count: int = 0

    def increment(self):
        self.count += 1

    def decrement(self):
        self.count -= 1


def index():
    return rx.hstack(
        rx.button(
            "Decrement",
            bg="#fef2f2",
            color="#b91c1c",
            border_radius="lg",
            on_click=ButtonState.decrement,
        ),
        rx.heading(
            ButtonState.count,
            font_size="2em",
            padding_x="0.5em",
        ),
        rx.button(
            "Increment",
            bg="#ecfdf5",
            color="#047857",
            border_radius="lg",
            on_click=ButtonState.increment,
        ),
    )

Button


The Button component is used to trigger an event or event, such as submitting a form, opening a dialog, canceling an event, or performing a delete operation.


  • Base Event Triggers

ButtonGroup


A group of buttons.


  • Base Event Triggers

IconButton


A button with an icon.


  • Base Event Triggers

← FormControlCheckbox →

Copyright © 2023 Pynecone, Inc.