Skip to main content
Button(props: {action: () => void, label: Component}): Component;
Button(label: string, action: () => void): Component;
Button(label: Component, action: () => void): Component;

Parameters

label
string | Component
The button’s label. Can be a string or any component.
action
() => void
The action to perform when the button is pressed.
props
{action: () => void, label: Component}
Configuration object with action and label properties.

Support

Usage

Simple text button

Button("Click me", () => {
    console.log("Button clicked!")
})

Button with component label

Button(
    HStack({ spacing: 8 }, [
        Image({ systemName: "star" }),
        Text("Favorite")
    ]),
    () => {
        console.log("Favorited!")
    }
)

Styled button

Button("Primary Action", () => {
    console.log("Primary action")
})
.foregroundStyle(Color("white"))
.background(Color("blue"))
.cornerRadius(8)
.padding()

Disabled button

Button("Disabled", () => {})
    .disabled(true)