The list of standard objects you can create from that menu isn’t one-to-one with the actual classes. I believe a “Button - TextMeshPro” is just a standard UnityEngine.UI.Button with a child that has a TMPro.TextMeshProUGUI component instead of a UnityEngine.UI.Text component.
Unfortunately that isn’t true, I just tried it, and it doesn’t work. It doesn’t work as a GameObject, either. Its doesn’t see that it is recognized as anything I can think to try.
I found a different way to do it for my use case – by putting a script on the button and accessing through that; I’m not sure if that will work in your use case, but that is what worked for me.
It’s not complicated. When you choose to add a “Button - TextMeshPro”, you get multiple objects with multiple components. It’s kind of like a Prefab pre-made recipe to combine text and clicky features in one.
The parent object inserted has the Button class component. Same Button used throughout standard Unity GUI. If you want to add click events or handle click events, or enable or disable clicking, refer to this Button component.
It also has an Image and Canvas Renderer, so it shows up on the canvas.
The child object inserted has the TextMeshProUGUI class component. This is for the text that will appear in the button on the canvas. If you want to set the text that appears, then refer to this TextMeshProUGUI component.
I figured out a fix. For whatever reason, there’s ambiguity when referencing Button as a component. To fix it, I just directly referenced UnityEngine.UI.Button when defining the variable instead of putting it at the top of the code: