Overview
TheButton class creates an interactive button element that can contain a label and/or an icon. It extends the Container class and provides a clickable interface element with automatic theme styling.
Constructor
The root element of the chart
Configuration settings for the button
Settings
label
A
Label element to display as the button’s text label.icon
A
Graphics element to display as the button’s icon.Inherited Settings
Button inherits all settings fromContainer, including:
width- Width of the buttonheight- Height of the buttonbackground- Background graphic (automatically created asRoundedRectangleif not provided)paddingTop,paddingRight,paddingBottom,paddingLeft- Padding valuesx,y- Position coordinatesopacity- Opacity (0-1)
Events
Button supports all standardContainer events:
click- Fired when the button is clickedpointerover- Fired when pointer moves over the buttonpointerout- Fired when pointer moves out of the buttonpointerdown- Fired when pointer is pressed down on the buttonpointerup- Fired when pointer is released on the button
Examples
Basic Button with Label
Button with Icon
Button with Both Label and Icon
Theme Tags
The button automatically receives the"button" theme tag and its background receives "button" and "background" tags, allowing for easy styling through themes.