Button(props: { action: () => void; label: Component }): Component;
Button(label: string, action: () => void): Component;
Button(label: Component, action: () => void): Component;
label
string | Component
required
The button’s visible content. Can be a plain string or any component for custom layouts.
Callback invoked when the button is tapped.
When using the object form:
Callback invoked when the button is tapped.
A component to use as the button label.
Support
Usage
Simple text button
Button("Save", () => {
console.log("Saved!")
})
Button(
HStack({ spacing: 8 }, [
Image({ systemName: "checkmark" }),
Text("Save")
]),
() => handleSave()
)
Button({
action: () => handleSave(),
label: HStack([
Image({ systemName: "checkmark" }),
Text("Save")
])
})
Button("Primary Action", () => {})
.foregroundStyle(Color("white"))
.padding({ horizontal: 16, vertical: 10 })
.background(Color("blue"))
.cornerRadius(8)
Button("Submit", () => {})
.disabled(true)
See Also