Clickable action button with variants and loading states.
npm run tsx:core-gallery
Property | Type | Required | Default | Description |
---|---|---|---|---|
children | string | any | No | - | Button content text or child components (shadcn-style) |
text | string | No | - | Button text (from component-schemas.ts) |
type | "button" | "submit" | "reset" | No | "button" | Button type for form handling |
onClick | () => void | No | - | Click event handler |
loading | boolean | No | false | Show loading state |
loadingText | string | No | "Loading..." | Text displayed during loading |
icon | string | No | - | Icon or glyph to display with text |
iconPosition | "left" | "right" | No | "left" | Icon placement relative to text |
fullWidth | boolean | No | false | Expand to 100% parent width |
pressed | boolean | No | - | Pressed state (from component-schemas) |
hover | boolean | No | - | Hover state (from component-schemas) |
BasePropsSchema
and includes all standard TUI component properties:
Property | Type | Default | Description |
---|---|---|---|
parent | blessed.Widgets.Node | - | Parent blessed element |
className | string | - | CSS-like class name for styling |
id | string | - | Unique identifier |
variant | ComponentVariant | "default" | Component variant (primary, secondary, destructive, outline, ghost, link, success, warning, error, info) |
size | ComponentSize | - | Component size (xs, sm, md, lg, xl) |
disabled | boolean | false | Whether component is disabled |
hidden | boolean | false | Whether component is hidden |
focusable | boolean | true | Whether component can receive focus |
keys | boolean | true | Enable keyboard input |
mouse | boolean | true | Enable mouse input |
Property | Type | Description |
---|---|---|
top | TerminalUnit | Top position |
left | TerminalUnit | Left position |
right | TerminalUnit | Right position |
bottom | TerminalUnit | Bottom position |
width | TerminalUnit | Component width (or 100% if fullWidth=true) |
height | TerminalUnit | Component height |
padding | PaddingConfig | Internal spacing |
margin | PaddingConfig | External spacing |
Property | Type | Description |
---|---|---|
bg | ColorValue | Background color |
fg | ColorValue | Foreground color |
border | BorderStyle | Border configuration |
borderColor | ColorValue | Border color |
borderStyle | "line" | "double" | "round" | "bold" | "classic" | "none" | Border style helper |
style | TextStyle | Text styling (bold, underline, etc.) |
animation | AnimationType | Animation type |
Method | Parameters | Return Type | Description |
---|---|---|---|
setText | text: string | void | Updates the button label content |
setLoading | loading: boolean, loadingText?: string | void | Toggle loading state with optional custom text |
setDisabled | disabled: boolean | void | Enable or disable the button |
setIcon | icon: string, position?: "left" | "right" | void | Set button icon and optional position |
destroy | - | void | Cleanup method from base component |
Method | Parameters | Return Type | Description |
---|---|---|---|
setVariant | variant: ComponentVariant | void | Updates component variant |
setSize | size: ComponentSize | void | Updates component size |
setState | state: ComponentState | void | Updates component state (default, hover, focus, active, disabled, loading) |
getConfig | - | ComponentConfig | Returns current configuration |
update | props: Partial<ButtonProps> | void | Updates component properties with re-render |
Method | Parameters | Return Type | Description |
---|---|---|---|
Button.create | props: ButtonProps | Button | Factory method to create new button instance |
Button.createGroup | buttons: ButtonProps[], options?: GroupOptions | Button[] | Create multiple buttons with automatic positioning |
fullWidth
for forms and primary actions on narrow layouts.