# Button Widget

#### General Setting

User can change following things in button widget:

* Widget Name - Name for widget which will be used data reference&#x20;

  For Example, if widget name is 'Button', then data of widget is referenced as Button.data as shown in below image.

<div align="center"><img src="https://365492316-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M7aTljSjWsfbXZ_OP_9%2Fuploads%2F6l1tEqGjenJQjBFTn4do%2FbuttonGenral1.png?alt=media&#x26;token=dec70f53-66f7-49ce-8331-208a1411fa04" alt="Configure Button Widget"></div>

* Show Title - User can show/hide widget title
* Title Color
* Background Color&#x20;

![Configure Button Widget ](https://365492316-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M7aTljSjWsfbXZ_OP_9%2Fuploads%2FSWy9YErYMzPPLbymSGZV%2FbuttonGeneral.png?alt=media\&token=10526229-cc7b-4ae4-b239-7948d207677a)

#### Widget Setting

In Widget Setting option, user can change following parameters:

* Value -  value for **Button.data** parameter in JSON object, that will be used for onClick Event.
* Button Color&#x20;
* Text Color
* Button Text

![Configure Button Widget ](https://365492316-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M7aTljSjWsfbXZ_OP_9%2Fuploads%2F1HWsBT8652Ay5w5FQ4ko%2FbuttonWidget.png?alt=media\&token=e384708e-76b4-4acf-94cc-f9329d2b818e)

#### Source

Button widget does not support Source settings.

#### Event Handling

Button onClick event is provided. User can choose MQTT or Action mode for onClick event.

**Using MQTT**

User needs to provide following parameters:

* event - Select **onClick** event from dropdown
* mode - Select mode as **MQTT**
* topic - Enter topic name directly. No need to provide accountID.
* Data parameters - Add new data parameter item. Each data parameter item represent a key-value pair. So select required parameter and give key name to it.

As shown in below images, for onClick event, MQTT mode is selected. It means when user clicks on the button, it will publish configured data parameters on given MQTT topic.

![Button Widget - Event handling using MQTT](https://365492316-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M7aTljSjWsfbXZ_OP_9%2Fuploads%2FhnsrPKaNyv6MBwUVB16p%2FbuttonMQTT1.png?alt=media\&token=f189a223-953c-47c5-a11a-f5f2c63f7b69)

![Button Widget - Event handling using MQTT](https://365492316-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M7aTljSjWsfbXZ_OP_9%2Fuploads%2FuYpeqtdqNvgbcn787BxC%2FbuttonMQTT2.png?alt=media\&token=907d4ba0-a2b1-4b81-9cc7-c2d1ef2a9e22)

So, as per the configuration shown in above images, when user clicks the button, JSON object with **buttonKey-UserRole** as key-value pair gets published on **buttonData** topic. Please refer below image for final output.

![Button Widget - Event handling using MQTT](https://365492316-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M7aTljSjWsfbXZ_OP_9%2Fuploads%2FYSxZqGS9mVRDZP4I1hD8%2FbuttonMQTT3.png?alt=media\&token=9ec8ea42-4aab-40e7-bc76-06150bde7bfb)

**Using Action**

User needs to provide following parameters:

* event - Select **onClick** event from dropdown
* mode - Select mode as **action**
* Action ID - Select required Action ID from dropdown

As shown in below images, for onClick event, **action** mode is selected. It means when user clicks on the button, it will trigger given Action with configured action parameters.

![Button Widget - Event handling using Actions Widget](https://365492316-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M7aTljSjWsfbXZ_OP_9%2Fuploads%2F5onjjrFse7vuRg80spKY%2FbuttonEventAction1.png?alt=media\&token=e99fd815-3599-4c35-a7c5-71139983a8b2)

![Button Widget - Event handling using Actions](https://365492316-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M7aTljSjWsfbXZ_OP_9%2Fuploads%2FFUc3JSBcKQmYLvQpmrt0%2FbuttonAction2.png?alt=media\&token=a25a8ce8-d4db-420d-b07e-33ac2e302d1f)

So, as per the example given in above images, when user clicks a button, **updateFirebaseCloud** action will trigger with JSON object of **buttonData-UserID** as key-value pair as input.
