MCPcopy
hub / github.com/StructuredLabs/preswald / button

Function button

preswald/interfaces/components.py:91–120  ·  view source on GitHub ↗

Create a button component that returns True when clicked.

(
    label: str,
    variant: str = "default",
    disabled: bool = False,
    loading: bool = False,
    size: float = 1.0,
    component_id: str | None = None,
    **kwargs
)

Source from the content-addressed store, hash-verified

89
90@with_render_tracking("button")
91def button(
92 label: str,
93 variant: str = "default",
94 disabled: bool = False,
95 loading: bool = False,
96 size: float = 1.0,
97 component_id: str | None = None,
98 **kwargs
99) -> ComponentReturn:
100 """Create a button component that returns True when clicked."""
101 service = PreswaldService.get_instance()
102
103 # Get current state or use default
104 current_value = service.get_component_state(component_id)
105 if current_value is None:
106 current_value = False
107
108 component = {
109 "type": "button",
110 "id": component_id,
111 "label": label,
112 "variant": variant,
113 "disabled": disabled,
114 "loading": loading,
115 "size": size,
116 "value": current_value,
117 "onClick": True, # Always enable click handling
118 }
119
120 return ComponentReturn(current_value, component)
121
122@with_render_tracking("chat")
123def chat(source: str, table: str | None = None, component_id: str | None = None, **kwargs) -> ComponentReturn:

Callers 1

button_demoFunction · 0.90

Calls 3

ComponentReturnClass · 0.90
get_component_stateMethod · 0.80
get_instanceMethod · 0.45

Tested by

no test coverage detected