Skip to main content

Button

The Button component is a versatile interactive element for triggering actions. It supports multiple types, sizes, icons, and states.

Overview

Button provides a complete action trigger solution with:

  • Multiple button types (primary, default, danger, text, link)
  • Icon support (left, right, or both)
  • Loading state
  • Block layout
  • Dashed border variant
  • Link functionality

Basic Usage

{
uuid: "my-button",
name: "submit_button",
component_type: "button",
input: {
label: { type: "string", value: "Submit" },
type: { type: "string", value: "primary" }
},
event: {
onClick: `
$formSubmitted = true;
await SubmitForm();
`
}
}

Component Inputs

PropertyTypeDefaultDescription
labelstring'Button'Button text
typestring'default'Type: 'default', 'primary', 'danger', 'text', 'link'
sizestring'medium'Size: 'small', 'medium', 'large'
shapestring-Shape: 'circle', 'round'
statestring'default'State: 'default', 'disabled'
loadingbooleanfalseShow loading spinner
blockbooleanfalseFull-width button
dashedbooleanfalseDashed border style
iconstring-Icon name
iconLeftstring-Left icon
iconRightstring-Right icon
iconPositionstring'left'Icon position
iconOnlybooleanfalseIcon-only mode
hrefstring-Link URL
targetstring-Link target (_blank, etc.)
ripplebooleantrueEnable ripple effect
ariaLabelstring-Accessibility label
htmlTypestring-HTML button type: 'button', 'submit', 'reset'

Events

onClick

Triggered: When button is clicked

event: {
onClick: `
$buttonClicked = true;
await PerformAction();
`
}

onButtonClicked

Triggered: Alternative click event

onLinkNavigation

Triggered: When link button navigates


Common Patterns

Form Submit Button

{
component_type: "button",
input: {
label: { type: "string", value: "Submit" },
type: { type: "string", value: "primary" },
htmlType: { type: "string", value: "submit" },
block: { type: "boolean", value: true }
},
inputHandlers: {
loading: `return $isSubmitting;`,
disabled: `return !$formValid;`
},
event: {
onClick: `
$isSubmitting = true;
try {
await SubmitForm($formData);
$submitSuccess = true;
} catch (error) {
$submitError = error.message;
} finally {
$isSubmitting = false;
}
`
}
}

Action Buttons Group

// Save button
{
component_type: "button",
input: {
label: { type: "string", value: "Save" },
type: { type: "string", value: "primary" },
icon: { type: "string", value: "save" }
},
event: { onClick: `await SaveChanges();` }
}

// Cancel button
{
component_type: "button",
input: {
label: { type: "string", value: "Cancel" },
type: { type: "string", value: "default" }
},
event: { onClick: `$editMode = false;` }
}

// Delete button
{
component_type: "button",
input: {
label: { type: "string", value: "Delete" },
type: { type: "string", value: "danger" },
icon: { type: "string", value: "trash" }
},
event: { onClick: `$showDeleteConfirm = true;` }
}
{
component_type: "button",
input: {
label: { type: "string", value: "View Documentation" },
type: { type: "string", value: "link" },
href: { type: "string", value: "https://docs.example.com" },
target: { type: "string", value: "_blank" },
iconRight: { type: "string", value: "external-link" }
}
}

See Also