How to send a MQTT message to a topic with a button

I want to do a button on Openhab that has no On/Off state like a Switch. Only to send a message to a topic when it is clicked. But I don’t know how to do this. I have done several Switches that are working, but I don’t know how to this button.
And is it possible that when the MQTT server get the message from a click on the button, that it will turn green for 3 seconds. How to do this?

Sitemaps or MainUI?

For sitemaps see mappings. You don’t say what the message actually is so :person_shrugging: . Maybe a String Item linked to a String Channel and set up the mapping to send the actual message you want to post.

Fir MainUI, most base widgets support configuration of an action. The action is what happens when you click on the widget. Set this to command the Item that is linked to the MQTT Channel. Or you can create a rule and have the action call the rule.

In sitemaps I don’t think you can control the color but you can set an Expire on the Item to update the Item to something like NULL after three seconds. That should gray out the button.

In MainUI you can use the same approach only you’ll need to use an expression to control the background color.

You can control the label color, value color, and icon color separately.

Right, but not the mappings’ button color which is what I was referring to.