Button(props: {action: () => void, label: Component}): Component;
Button(label: string, action: () => void): Component;
Button(label: Component, action: () => void): Component;
Parameters
The button’s label. Can be a string or any component.
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(
HStack({ spacing: 8 }, [
Image({ systemName: "star" }),
Text("Favorite")
]),
() => {
console.log("Favorited!")
}
)
Button("Primary Action", () => {
console.log("Primary action")
})
.foregroundStyle(Color("white"))
.background(Color("blue"))
.cornerRadius(8)
.padding()
Button("Disabled", () => {})
.disabled(true)