rx.button("Click Me!")
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",
)
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",
)
rx.button_group(
rx.button(rx.icon(tag="minus"), color_scheme="red"),
rx.button(rx.icon(tag="add"), color_scheme="green"),
is_attached=True,
)
on_click
event handler. 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,
),
)
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.
A group of buttons.
A button with an icon.